-
-
Notifications
You must be signed in to change notification settings - Fork 558
fix: Windows build compatibility #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,10 +33,11 @@ export async function getRipgrepPath(): Promise<string> { | |||||||||||||||||||||||||||||
| // @vscode/ripgrep import or binary resolution failed, continue to fallbacks | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Strategy 2: Try system ripgrep using 'which' command | ||||||||||||||||||||||||||||||
| // Strategy 2: Try system ripgrep using 'which' (Unix) or 'where' (Windows) | ||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
| const systemRg = process.platform === 'win32' ? 'rg.exe' : 'rg'; | ||||||||||||||||||||||||||||||
| const result = execSync(`which ${systemRg}`, { encoding: 'utf-8' }).trim(); | ||||||||||||||||||||||||||||||
| const whichCmd = process.platform === 'win32' ? 'where' : 'which'; | ||||||||||||||||||||||||||||||
| const result = execSync(`${whichCmd} ${systemRg}`, { encoding: 'utf-8' }).trim().split(/\r?\n/)[0]; | ||||||||||||||||||||||||||||||
| if (result && existsSync(result)) { | ||||||||||||||||||||||||||||||
| cachedRgPath = result; | ||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The code assumes execSync returns a single path and picks the first line; on Windows 'where' can return multiple paths (including shims) or quoted paths. Replace the single-line extraction with robust parsing: capture full stdout, split into candidate lines, trim quotes/whitespace, and iterate to return the first existing candidate (also add a short timeout and maxBuffer to avoid blocking indefinitely). [possible bug] Severity Level: Critical 🚨
Suggested change
Why it matters? ⭐The PR currently grabs only the first line of execSync output. On Windows 'where' Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/utils/ripgrep-resolver.ts
**Line:** 40:42
**Comment:**
*Possible Bug: The code assumes execSync returns a single path and picks the first line; on Windows 'where' can return multiple paths (including shims) or quoted paths. Replace the single-line extraction with robust parsing: capture full stdout, split into candidate lines, trim quotes/whitespace, and iterate to return the first existing candidate (also add a short timeout and maxBuffer to avoid blocking indefinitely).
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Using the platform-specific literal 'rg.exe' for Windows may miss valid installs where the executable is registered as 'rg' (Windows 'where' will find 'rg' just as well), causing the lookup to fail; use the generic 'rg' name so the locator command can find both 'rg' and 'rg.exe'. [logic error]
Severity Level: Minor⚠️
Why it matters? ⭐
The current code special-cases Windows by using 'rg.exe'. While that usually works,
using the generic 'rg' is more robust: Windows 'where' can resolve executables
via PATHEXT and will find 'rg' whether it's listed as 'rg' or 'rg.exe' (and it
also covers shims/aliases that may not include the .exe suffix). This is a small,
safe improvement that reduces the chance of a false negative when locating ripgrep.
Prompt for AI Agent 🤖