Skip to content

fix(ripgrep): support @vscode/ripgrep >=1.18 platform-package layout (#1024)#1032

Merged
navedmerchant merged 6 commits into
mainfrom
issue/1024
Jul 27, 2026
Merged

fix(ripgrep): support @vscode/ripgrep >=1.18 platform-package layout (#1024)#1032
navedmerchant merged 6 commits into
mainfrom
issue/1024

Conversation

@edelauna

@edelauna edelauna commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #1024

Description

VS Code 1.130+ ships @vscode/ripgrep >=1.18, which changed the binary layout: instead of a single bundled binary, rg now lives inside a platform-specific optional package (e.g. @vscode/ripgrep-win32-x64). Our candidate path list only covered the old layouts, so getBinPath returned undefined on affected installs.

When that happened, listFiles threw "Could not find ripgrep binary", which propagated uncaught through getEnvironmentDetails and stalled every task at 0% before the first API call.

Changes:

  • Added the @vscode/ripgrep-${platform}-${arch} and unpacked-asar variants to ripgrepCandidatePaths, reading process.env.npm_config_arch || process.arch at call time to match the wrapper's own resolution logic
  • Wrapped listFiles in a try/catch in getEnvironmentDetails so a missing ripgrep binary degrades gracefully (shows a message in context) rather than hanging the task

Test Procedure

Unit tests cover all new candidate paths including the platform-package layout, arch override, and the graceful fallback when listFiles throws.

pnpm test -- src/services/ripgrep/__tests__/index.spec.ts src/core/environment/__tests__/getEnvironmentDetails.spec.ts

Pre-Submission Checklist

Summary by CodeRabbit

  • Bug Fixes

    • Improved Ripgrep binary detection across newer platform-specific package layouts and unpacked installations.
    • Respect architecture overrides when locating the Ripgrep binary.
    • Environment details now remain available when workspace file listing fails.
    • File listing failures are displayed as clear availability notices, including unexpected error values.
  • Tests

    • Added regression coverage for platform-specific binaries, unpacked installations, architecture overrides, and file-listing failures.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds platform-specific VS Code ripgrep path probing for standard and unpacked package layouts, including architecture overrides. Workspace file-listing failures are now reported in environment details rather than propagated.

Changes

Runtime resilience

Layer / File(s) Summary
Platform-package resolution
src/services/ripgrep/index.ts, src/services/ripgrep/__tests__/index.spec.ts
Ripgrep resolution now probes @vscode/ripgrep-<platform>-<arch> layouts in standard and unpacked directories, with coverage for npm_config_arch.
File-listing error handling
src/core/environment/getEnvironmentDetails.ts, src/core/environment/__tests__/getEnvironmentDetails.spec.ts
Workspace file-listing failures are caught and rendered as unavailable messages for both Error and non-Error rejection values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: hannesrudolph

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: adding support for the @vscode/ripgrep >=1.18 platform-specific layout.
Description check ✅ Passed The description covers the required issue link, implementation summary, testing steps, and checklist, with only minor template sections omitted.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/1024

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/environment/getEnvironmentDetails.ts 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/services/ripgrep/__tests__/index.spec.ts`:
- Around line 120-138: The test suite lacks coverage for the swallowed
package-resolution error in getBinPath. Add a package-local test where the first
createRequire(...).resolve() call throws, configure the required mocks for that
resolution path, and assert that getBinPath(appRoot) returns undefined.

In `@src/services/ripgrep/index.ts`:
- Line 121: Update resolvePlatformRipgrepPath() to derive the architecture using
process.env.npm_config_arch || process.arch, matching the wrapper’s package
resolution, and use that value when constructing the `@vscode/ripgrep` package
name. Add a test covering npm_config_arch overrides.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f37a96eb-6392-4bcf-a0bb-b0a480980a40

📥 Commits

Reviewing files that changed from the base of the PR and between 2db2af0 and 865951c.

📒 Files selected for processing (2)
  • src/services/ripgrep/__tests__/index.spec.ts
  • src/services/ripgrep/index.ts

Comment thread src/services/ripgrep/__tests__/index.spec.ts Outdated
Comment thread src/services/ripgrep/index.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/environment/__tests__/getEnvironmentDetails.spec.ts`:
- Around line 454-457: Update the test “should not throw when listFiles rejects
with ripgrep not found” to await getEnvironmentDetails directly and assert that
the returned environment-details string contains the expected fallback message.
Remove the invalid `.resolves.not.toThrow()` assertion while preserving the
mocked ripgrep rejection.

In `@src/services/ripgrep/__tests__/index.spec.ts`:
- Around line 123-142: Update the npm_config_arch test around getBinPath so the
environment override is applied before the module captures its platform-package
constant, and ensure the module is reloaded or candidate paths are computed
dynamically. Keep the assertion targeted to the overridden architecture and
restore the environment and module state afterward.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f3af62a8-f7fa-4026-bda6-f992a487aa10

📥 Commits

Reviewing files that changed from the base of the PR and between 865951c and 0a57e84.

📒 Files selected for processing (4)
  • src/core/environment/__tests__/getEnvironmentDetails.spec.ts
  • src/core/environment/getEnvironmentDetails.ts
  • src/services/ripgrep/__tests__/index.spec.ts
  • src/services/ripgrep/index.ts

Comment thread src/core/environment/__tests__/getEnvironmentDetails.spec.ts Outdated
Comment thread src/services/ripgrep/__tests__/index.spec.ts
@edelauna edelauna changed the title fix(ripgrep): resolve platform-specific binary for @vscode/ripgrep >=… fix(ripgrep): support @vscode/ripgrep >=1.18 platform-package layout (#1024) Jul 26, 2026
@edelauna
edelauna marked this pull request as ready for review July 26, 2026 23:41
@navedmerchant
navedmerchant enabled auto-merge July 26, 2026 23:47
@navedmerchant
navedmerchant added this pull request to the merge queue Jul 26, 2026
Merged via the queue into main with commit d27153a Jul 27, 2026
14 checks passed
@navedmerchant
navedmerchant deleted the issue/1024 branch July 27, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] API Request stuck at 0% after opening any workspace (Could not find ripgrep binary)

2 participants