Skip to content

Commit 3355601

Browse files
authored
Merge pull request #150 from luojiyin1987/fix/issue-144-ripgrep-fallback
fix(ripgrep): use @vscode/ripgrep instead of missing vendor binary
2 parents 45c9dae + 84df44a commit 3355601

2 files changed

Lines changed: 5 additions & 23 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@modelcontextprotocol/sdk": "^1.15.1",
5454
"@types/lodash-es": "^4.17.12",
5555
"@types/react": "^19.1.8",
56+
"@vscode/ripgrep": "^1.17.0",
5657
"ansi-escapes": "^7.0.0",
5758
"chalk": "^5.4.1",
5859
"cli-highlight": "^2.1.11",

src/utils/ripgrep.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { findActualExecutable } from 'spawn-rx'
2+
import { rgPath as vsCodeRgPath } from '@vscode/ripgrep'
23
import { memoize } from 'lodash-es'
3-
import { fileURLToPath, resolve } from 'node:url'
4-
import * as path from 'path'
54
import { logError } from './log'
65
import { execFileNoThrow } from './execFileNoThrow'
76
import { execFile } from 'child_process'
87
import debug from 'debug'
98

10-
const __filename = fileURLToPath(import.meta.url)
11-
const __dirname = resolve(
12-
__filename,
13-
process.env.NODE_ENV === 'test' ? '../..' : '.',
14-
)
15-
169
const d = debug('claude:ripgrep')
1710

1811
const useBuiltinRipgrep = !!process.env.USE_BUILTIN_RIPGREP
@@ -29,21 +22,9 @@ const ripgrepPath = memoize(() => {
2922
// path rather than just returning 'rg'
3023
return cmd
3124
} else {
32-
// Use the one we ship in-box
33-
const rgRoot = path.resolve(__dirname, 'vendor', 'ripgrep')
34-
if (process.platform === 'win32') {
35-
// NB: Ripgrep doesn't ship an aarch64 binary for Windows, boooooo
36-
return path.resolve(rgRoot, 'x64-win32', 'rg.exe')
37-
}
38-
39-
const ret = path.resolve(
40-
rgRoot,
41-
`${process.arch}-${process.platform}`,
42-
'rg',
43-
)
44-
45-
d('internal ripgrep resolved as: %s', ret)
46-
return ret
25+
// Use @vscode/ripgrep which auto-downloads platform-specific binary
26+
d('Using @vscode/ripgrep: %s', vsCodeRgPath)
27+
return vsCodeRgPath
4728
}
4829
})
4930

0 commit comments

Comments
 (0)