fix: consolidate bun global bin detection and add symlink workaround#385
fix: consolidate bun global bin detection and add symlink workaround#385
Conversation
The previous cli.js fallback (66e09c5) handled the case where bun doesn't create the bin symlink, but as a separate code path. This consolidates the cli.js check into the existing BUN_GLOBAL_CLAUDE_PATHS loop (which already checks both ~/.bun/bin and ~/.cache/.bun/bin), eliminating duplicate code. Also adds a post-install `ln -sf` workaround: after `bun install -g` succeeds, if no claude symlink exists, manually create it pointing to cli.js. This fixes the root cause rather than just working around it at detection time. Same fix applied to Codex CLI install.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3179f5c74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let install_cmd = if has_bun { | ||
| // Ensure Bun's bin is in PATH and install globally | ||
| r#"export PATH="/root/.bun/bin:/root/.cache/.bun/bin:$PATH" && bun install -g @anthropic-ai/claude-code@latest"# | ||
| r#"export PATH="/root/.bun/bin:/root/.cache/.bun/bin:$PATH" && bun install -g @anthropic-ai/claude-code@latest && { test -x /root/.bun/bin/claude || test -x /root/.cache/.bun/bin/claude || ln -sf ../install/global/node_modules/@anthropic-ai/claude-code/cli.js /root/.bun/bin/claude 2>/dev/null; } ; true"# |
There was a problem hiding this comment.
Keep Claude bun install failures visible
The appended ; true forces this shell command to exit successfully even when bun install -g @anthropic-ai/claude-code@latest fails (for example, registry/network errors). That means the output.status.success() check no longer catches real install failures on the bun path, and users get a misleading follow-up error (install completed but ... not available) instead of the actual installer stderr/stdout. Please avoid unconditional success here and only suppress non-critical symlink-step failures.
Useful? React with 👍 / 👎.
|
|
||
| let install_cmd = if has_bun { | ||
| r#"export PATH="/root/.bun/bin:/root/.cache/.bun/bin:$PATH" && bun install -g @openai/codex@latest 2>&1"# | ||
| r#"export PATH="/root/.bun/bin:/root/.cache/.bun/bin:$PATH" && bun install -g @openai/codex@latest 2>&1 && { test -x /root/.bun/bin/codex || test -x /root/.cache/.bun/bin/codex || ln -sf ../install/global/node_modules/@openai/codex/bin/codex.js /root/.bun/bin/codex 2>/dev/null; } ; true"# |
There was a problem hiding this comment.
Preserve Codex bun install exit status
This command also ends with ; true, which masks non-zero exit codes from bun install -g @openai/codex@latest. In bun-enabled environments, installation failures are therefore treated as success by output.status.success(), so the function can no longer report the real install error and instead emits a generic "install completed but ... not available" message. The unconditional true should be removed or narrowed to only the optional symlink workaround.
Useful? React with 👍 / 👎.
…h node
- Move `|| true` inside the `{ }` group so only the optional symlink
workaround is suppressed, not bun install failures themselves.
Previously `; true` after the group masked all exit codes.
- When the cli.js fallback path is matched, return `node <path>` instead
of the bare path, since cli.js is a raw JS file that needs a runtime.
Bin symlinks have shebangs and can run directly.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a4a0a5a. Configure here.
| } | ||
|
|
||
| Err(format!( | ||
| "Claude Code install completed but '{}' is still not available in workspace PATH.", |
There was a problem hiding this comment.
Duplicated bun path detection loop logic
Low Severity
The bun-path detection loop (iterate over BUN_GLOBAL_CLAUDE_PATHS + BUN_GLOBAL_CLAUDE_CLI_JS, check command_available for the path and then for node/bun runtimes, build the appropriate command string) is duplicated nearly identically in two places within ensure_claudecode_cli_available — once for pre-install detection and once for post-install detection. A future change to the resolution logic (e.g., adding a new path or changing runtime priority) risks updating only one copy. Extracting a small helper function would eliminate this risk.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a4a0a5a. Configure here.


Summary
~/.bun/bin/claude,~/.cache/.bun/bin/claude, and the directcli.jspath — removing duplicate standalone fallback blocks from 66e09c5ln -sfworkaround: afterbun install -gsucceeds, if no claude symlink exists, manually creates it pointing tocli.js(fixes the root cause instead of just detecting it)Test plan
misccontainer,claude --versionreturns2.1.107Note
Medium Risk
Changes CLI discovery and auto-install command strings for Claude Code/Codex in
mission_runner, which could impact mission execution if path resolution or shell snippets are wrong. Scope is localized but affects runtime tooling availability in workspaces.Overview
Improves Claude Code CLI resolution by consolidating bun global-path checks into a single loop that searches both
~/.bun/binand~/.cache/.bun/bin, and falls back to running the installedcli.jsdirectly when the bun bin symlink is missing.Hardens auto-install when using bun by adding a post-install symlink workaround: after
bun install -g, it verifiesclaude/codexexists and, if not, creates a symlink in~/.bun/binpointing at the installed JS entrypoint. Error messaging now includes which bun paths were checked.Reviewed by Cursor Bugbot for commit a4a0a5a. Bugbot is set up for automated code reviews on this repo. Configure here.