Commit 3e07e4c
fix: resolve ripgrep from @vscode/ripgrep-universal and the system PATH (#248)
* fix: resolve ripgrep from @vscode/ripgrep-universal and the system PATH
search_files and list_files threw "Could not find ripgrep binary" on VS Code Insiders, whose staged-install builds ship ripgrep as @vscode/ripgrep-universal with the binary nested under bin/<platform>-<arch>/ — a layout getBinPath did not recognize. getBinPath now also checks that layout, and falls back to ripgrep on the system PATH when no copy is found in the VS Code install (covering VS Code forks and headless/CLI hosts).
* fix: drop the PATH fallback per review feedback
Per #248 review (edelauna): rely only on VS Code's bundled ripgrep — the fix keeps the @vscode/ripgrep-universal/bin/<platform>-<arch>/ resolution that VS Code Insiders' staged-install builds use (the original bug) but drops the system-PATH probe. This also addresses the Copilot trust-model note at the old line 111 (a PATH-resolved rg could be user-controlled) and clears the codecov gap — the uncovered lines were the PATH helper.
* fix: resolve ripgrep via @vscode/ripgrep import per review feedback
Per #248 review (edelauna): replace the appRoot path-probing with an @vscode/ripgrep import. VS Code's extension host aliases @vscode/ripgrep to its own @vscode/ripgrep-universal (extHostRequireInterceptor.ts L97-101), so ripgrep resolution stays in sync with whatever VS Code ships with — including the Insiders staged-install layout — without maintaining a hardcoded path list across VS Code repackagings.
getBinPath shrinks to a try/catch around await import + the .asar → .asar.unpacked substitution from VS Code's own resolver (src/vs/base/node/ripgrep.ts).
- @vscode/ripgrep added as a src devDep (types only; the binary is not shipped in the VSIX).
- @vscode/ripgrep added to external in src/esbuild.mjs so the require is preserved at runtime for VS Code's interceptor.
- Tests cover all four branches: rgPath returned, .asar substitution applies, rgPath undefined, rgPath access throws.
* revert: drop @vscode/ripgrep require attempt for now
Diagnostic from a Windows VS Code stable 1.121.0 install (see #248
review thread) showed that require("@vscode/ripgrep") throws — VS
Code's extHost interceptor aliases the require to
@vscode/ripgrep-universal, but that package isn't installed on
builds that haven't completed the package-rename migration (which
includes current stable). The path-probe fallback in the diagnostic
test build was what actually resolved ripgrep on that install.
Reverts to the prior shape: hardcoded paths covering both the
@vscode/ripgrep and @vscode/ripgrep-universal layouts under
vscode.env.appRoot. Also drops the @vscode/ripgrep devDep, the
esbuild external entry, the loadRipgrep wrapper file, and the tests
that mocked it — all dead with the revert.
VS Code's package-rename migration will be tracked in a separate
issue; once it lands across stable + Insiders the require approach
can be revisited with empirical evidence of which mechanism VS Code
expects 3rd-party extensions to use.
* docs: drop stale PATH reference from getBinPath header
Per CodeRabbit's review of the revert commit: the module-level
comment still listed "or on the system PATH" as a resolution source,
but the PATH probe was removed two commits back. Updated to match
the actual behavior (probe paths under vscode.env.appRoot only).
* test: cover the asar.unpacked universal layout
CodeRabbit nit on the latest commit: add explicit coverage for the
node_modules.asar.unpacked/@vscode/ripgrep-universal/<plat>-<arch>/<rg>
candidate path. Mirrors the existing universal-layout test but
targets the .asar.unpacked variant — the exact staged-install
shape that motivated the universal-layout entries in the first
place.
---------
Co-authored-by: 0xMink <260166390+0xMink@users.noreply.github.com>1 parent d63e7bd commit 3e07e4c
2 files changed
Lines changed: 65 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
4 | 14 | | |
5 | 15 | | |
6 | 16 | | |
| |||
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
| |||
92 | 103 | | |
93 | 104 | | |
94 | 105 | | |
95 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
96 | 109 | | |
97 | 110 | | |
98 | 111 | | |
| |||
0 commit comments