Skip to content

fix: consolidate bun global bin detection and add symlink workaround#385

Merged
Th0rgal merged 2 commits intomasterfrom
fix/bun-claude-symlink
Apr 14, 2026
Merged

fix: consolidate bun global bin detection and add symlink workaround#385
Th0rgal merged 2 commits intomasterfrom
fix/bun-claude-symlink

Conversation

@Th0rgal
Copy link
Copy Markdown
Owner

@Th0rgal Th0rgal commented Apr 14, 2026

Summary

  • Consolidates the bun global bin detection into a single loop that checks ~/.bun/bin/claude, ~/.cache/.bun/bin/claude, and the direct cli.js path — removing duplicate standalone fallback blocks from 66e09c5
  • Adds a post-install ln -sf workaround: after bun install -g succeeds, if no claude symlink exists, manually creates it pointing to cli.js (fixes the root cause instead of just detecting it)
  • Same symlink workaround applied to Codex CLI install path

Test plan

  • Verified on prod server: manually created symlink in misc container, claude --version returns 2.1.107
  • Deployed to both prod and dev services
  • Create a new container workspace and run a Claude Code mission to verify auto-install works end-to-end

Note

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/bin and ~/.cache/.bun/bin, and falls back to running the installed cli.js directly 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 verifies claude/codex exists and, if not, creates a symlink in ~/.bun/bin pointing 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.

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.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandboxed-dashboard Ready Ready Preview, Comment Apr 14, 2026 8:46am
sandboxed-sh Ready Ready Preview, Comment Apr 14, 2026 8:46am

Request Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/api/mission_runner.rs Outdated
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"#
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/api/mission_runner.rs Outdated

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"#
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/api/mission_runner.rs Outdated
Comment thread src/api/mission_runner.rs Outdated
…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.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/api/mission_runner.rs
}

Err(format!(
"Claude Code install completed but '{}' is still not available in workspace PATH.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a4a0a5a. Configure here.

@Th0rgal Th0rgal merged commit 8e43f43 into master Apr 14, 2026
15 of 16 checks passed
@Th0rgal Th0rgal deleted the fix/bun-claude-symlink branch April 14, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant