fix(fish): prevent hoisted bun npm stub from shadowing real native bun - #2008
Conversation
Global node_modules/.bin was ordered ahead of ~/.bun/bin on PATH, so a transitively hoisted `bun`/`bunx` npm stub (Windows .exe placeholder) shadowed the real native bun. Re-prepend ~/.bun/bin last so it stays frontmost while global CLIs still resolve.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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.
Code Review
This pull request adjusts the path ordering in the Fish shell configuration to ensure that the native bun binary path (~/.bun/bin) takes precedence over the global node_modules/.bin path, preventing npm stubs from shadowing the real binary. The reviewer suggested refactoring the duplicated fish_add_path blocks in both loginShellInit and interactiveShellInit into a single reusable Nix let binding to adhere to the DRY principle.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # ~/.bun/bin last => frontmost, so the real native bun/bunx always win over | ||
| # any hoisted `bun` npm stub living in the global node_modules/.bin above. | ||
| fish_add_path -p -m ~/.bun/bin |
There was a problem hiding this comment.
The entire block of fish_add_path commands (lines 50-62) is duplicated identically in both loginShellInit and interactiveShellInit (lines 75-87).
To adhere to the DRY (Don't Repeat Yourself) principle and prevent future maintenance issues (such as paths drifting out of sync when added, removed, or reordered), consider extracting this common path setup block into a Nix let binding at the top of the file.
Suggested Refactoring
At the top of home-manager/programs/fish/default.nix:
let
commonPaths = ''
# Last line = highest priority (-p -m prepends+moves; last call ends up at front of fish_user_paths)
fish_add_path -p -m /nix/var/nix/profiles/default/bin
fish_add_path -p -m ~/.nix-profile/bin
fish_add_path -p -m /etc/profiles/per-user/${config.home.username}/bin
fish_add_path -p -m ~/go/bin
fish_add_path -p -m ~/.local/bin
fish_add_path -p -m ~/.cargo/bin
fish_add_path -p -m ~/.local/scripts
fish_add_path -p -m /opt/homebrew/opt/postgresql@18/bin
fish_add_path -p -m /opt/homebrew/bin
fish_add_path -p -m ~/.bun/install/global/node_modules/.bin
# ~/.bun/bin last => frontmost, so the real native bun/bunx always win over
# any hoisted `bun` npm stub living in the global node_modules/.bin above.
fish_add_path -p -m ~/.bun/bin
'';
in
{
# ...
}Then, reference it in both shell initialization blocks:
loginShellInit = ''
if test -f /opt/homebrew/bin/brew
eval "$(/opt/homebrew/bin/brew shellenv)"
end
${commonPaths}
'';
interactiveShellInit = ''
source ${config.home.homeDirectory}/.config/fish/functions/_hm_load_env_file.fish
_hm_load_env_file
set fish_greeting
set fish_theme dracula
if test -f /opt/homebrew/bin/brew
eval "$(/opt/homebrew/bin/brew shellenv)"
end
${commonPaths}
# Worktrunk shell init
if type -q wt
wt config shell init fish | source
end
# ...
'';* fix(shell): update test to match bun PATH reorder from #2008 * feat: track moshi-hook entries in dotfiles for all agents Inline moshi-hook entries into tracked hook configs so home-manager activation deploys them without needing a separate moshi-hook install. JSON hooks (claude, codex, cursor, gemini, grok): - Add moshi-hook entries for PermissionRequest, SessionStart, UserPromptSubmit, Stop, SessionEnd, Pre/PostToolUse - Use bare 'moshi-hook' command (on PATH) instead of hardcoded /home/ubuntu/.local/bin path for cross-platform portability TypeScript plugins (omp, pi, opencode): - Track auto-generated moshi-hooks.ts via home.file in nix configs - Replace hardcoded helperBinary path with process.env.HOME * fix: format moshi-hooks.ts files with biome * feat: add moshi-update target to sync moshi-hook configs * fix: format update-moshi-hooks.sh with shfmt * fix: add moshi-hooks spec, guard moshi-update in CI
Problem
which bunresolved to~/.bun/install/global/node_modules/.bin/bun, a symlink tobun.exe(a Windows placeholder stub, ~450 bytes). Thebunnpm package gets transitively hoisted into the global tree duringinstall-npm-globals, and its.bin/bunshadowed the real native bun.Root cause
home-manager/programs/fish/default.nixordered~/.bun/install/global/node_modules/.binahead of~/.bun/binon PATH (both inshellInitand thefish_add_pathblocks). Global CLIs are meant to be frontmost, but that also let a hoistedbun/bunxstub win over the real binary at~/.bun/bin.Fix
Re-prepend
~/.bun/binlast (frontmost) so the real native bun/bunx always win, while global CLIs still resolve from the node_modules.binbehind it. Applied toshellInit,loginShellInit, andinteractiveShellInit.Also removed the corrupt stub from disk (
~/.bun/install/global/node_modules/bun+ its.binsymlinks); real bun (1.3.14) now resolves.Requires
make switch/ home-manager rebuild to take effect in login shells.Summary by cubic
Fixes PATH ordering in
fishso the real nativebun/bunxin ~/.bun/bin always win over a hoisted npm stub in ~/.bun/install/global/node_modules/.bin. This prevents calling the Windows stub and ensures the correct binary runs.Bug Fixes
Migration
make switch) to apply in new shells.Written for commit baa7a5e. Summary will update on new commits.