fix: resolve bun.exe when npm shim is in PATH#1621
fix: resolve bun.exe when npm shim is in PATH#1621zerone0x wants to merge 1 commit intothedotmack:mainfrom
Conversation
Fixes thedotmack#1595 Co-Authored-By: Claude <noreply@anthropic.com>
Summary by CodeRabbit
WalkthroughBoth files update Windows-specific Bun binary resolution logic. Instead of returning 'bun' when Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
plugin/scripts/bun-runner.js (2)
100-105: Minor inconsistency withbun-resolver.tscandidate paths.The TypeScript version (
bun-resolver.tsline 24) includes an additional candidate usingUSERPROFILE:join(process.env.USERPROFILE || homedir(), '.bun', 'bin', 'bun.exe'),This file omits that path. While
homedir()andUSERPROFILEtypically resolve identically on Windows, adding it here would maintain exact parity.📝 Suggested addition for consistency
const bunPaths = IS_WINDOWS ? [ join(homedir(), '.bun', 'bin', 'bun.exe'), + join(process.env.USERPROFILE || homedir(), '.bun', 'bin', 'bun.exe'), join(windowsAppData, 'npm', 'node_modules', 'bun', 'bin', 'bun.exe') ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugin/scripts/bun-runner.js` around lines 100 - 105, The bunPaths array for IS_WINDOWS is missing the USERPROFILE-based candidate present in bun-resolver.ts; update the bunPaths declaration (used with IS_WINDOWS, windowsAppData, homedir) to include a candidate that uses process.env.USERPROFILE || homedir() joining '.bun', 'bin', 'bun.exe' so the JS runner has identical Windows search paths as bun-resolver.ts.
58-94: Logic correctly mirrorsbun-resolver.ts.The Windows resolution logic is identical to the TypeScript version, which aligns with the PR objective to keep them in sync.
Consider future consolidation: Both files now have identical complex resolution logic. If feasible,
bun-runner.jscould potentially import from a shared module to avoid maintaining duplicate code. However, given thatbun-runner.jsis a standalone Node.js script (no build step) and needs to work independently, the current duplication is acceptable.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugin/scripts/bun-runner.js` around lines 58 - 94, The Windows bun resolution logic duplicates the implementation in bun-resolver.ts; add a short comment immediately above the Windows-resolution block in plugin/scripts/bun-runner.js (the section that checks IS_WINDOWS, parses pathCheck.stdout, and searches for exeCandidate/plainCandidate/cmdCandidate) stating that this logic intentionally mirrors bun-resolver.ts and explaining why it must remain standalone (no build step) to prevent future maintainers from removing or attempting to centralize it; keep the comment concise and reference bun-resolver.ts by name.src/npx-cli/utils/bun-resolver.ts (1)
43-44: Docstring is now inaccurate for Windows behavior.The comment states it returns
'bun'if found in PATH, but the new Windows logic returns the full path instead. Consider updating to clarify this platform difference.📝 Suggested docstring update
- * Returns the absolute path to the binary, `'bun'` if it is in PATH, - * or `null` if Bun cannot be found. + * Returns the absolute path to the binary, `'bun'` if it is in PATH (non-Windows), + * the resolved `.exe` path on Windows, or `null` if Bun cannot be found.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/npx-cli/utils/bun-resolver.ts` around lines 43 - 44, Update the docstring for the exported resolver (resolveBunPath) in src/npx-cli/utils/bun-resolver.ts to reflect the Windows-specific behavior: describe that the function returns a path string when Bun is found (on Windows this will be the absolute path to the bun executable; on POSIX it will return 'bun' when using PATH or an absolute path when resolved), and returns null if Bun cannot be found; replace the current line "Returns the absolute path to the binary, 'bun' if it is in PATH, or null if Bun cannot be found." with this clarified platform-aware description.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@plugin/scripts/bun-runner.js`:
- Around line 100-105: The bunPaths array for IS_WINDOWS is missing the
USERPROFILE-based candidate present in bun-resolver.ts; update the bunPaths
declaration (used with IS_WINDOWS, windowsAppData, homedir) to include a
candidate that uses process.env.USERPROFILE || homedir() joining '.bun', 'bin',
'bun.exe' so the JS runner has identical Windows search paths as
bun-resolver.ts.
- Around line 58-94: The Windows bun resolution logic duplicates the
implementation in bun-resolver.ts; add a short comment immediately above the
Windows-resolution block in plugin/scripts/bun-runner.js (the section that
checks IS_WINDOWS, parses pathCheck.stdout, and searches for
exeCandidate/plainCandidate/cmdCandidate) stating that this logic intentionally
mirrors bun-resolver.ts and explaining why it must remain standalone (no build
step) to prevent future maintainers from removing or attempting to centralize
it; keep the comment concise and reference bun-resolver.ts by name.
In `@src/npx-cli/utils/bun-resolver.ts`:
- Around line 43-44: Update the docstring for the exported resolver
(resolveBunPath) in src/npx-cli/utils/bun-resolver.ts to reflect the
Windows-specific behavior: describe that the function returns a path string when
Bun is found (on Windows this will be the absolute path to the bun executable;
on POSIX it will return 'bun' when using PATH or an absolute path when
resolved), and returns null if Bun cannot be found; replace the current line
"Returns the absolute path to the binary, 'bun' if it is in PATH, or null if Bun
cannot be found." with this clarified platform-aware description.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b6428f19-44a2-4303-b6f6-43fe918a0014
📒 Files selected for processing (2)
plugin/scripts/bun-runner.jssrc/npx-cli/utils/bun-resolver.ts
|
Closed during the April 2026 backlog cleanup. This was verified already-fixed in v12.1.1 HEAD. Please update to the latest build. If you still see the issue on current version, open a fresh ticket with repro. |
Summary
Testing