Repository navigation
Find Claude CLI in well-known locations and clarify the missing-CLI error - #1177
Conversation
…rror Packaged bb builds inline the Claude Agent SDK into the bridge bundle and do not ship the SDK's native platform package, so the SDK's bundled-binary fallback always fails there. When the login-shell PATH probe also misses the user's claude install (for example ~/.local/bin), sessions fail with the SDK's raw "Native CLI binary for darwin-arm64 not found" error. - Check well-known Claude install locations (~/.local/bin/claude, ~/.claude/local/claude, /opt/homebrew/bin/claude, /usr/local/bin/claude) when PATH discovery finds nothing. - Replace the SDK's "reinstall @anthropic-ai/claude-agent-sdk" guidance with a bb error that points at installing Claude Code or setting BB_CLAUDE_CODE_EXECUTABLE. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🚨 SLOP COP 🚨 · I am the Slop Cop. I am reviewing this pull request for security, code quality, architecture, performance, and test coverage. I will also test the affected behavior where practical. I will post one final review after the parallel checks finish. |
| // guidance is wrong for bb users; point them at the real remedies instead. | ||
| const MISSING_NATIVE_CLI_PATTERN = /Native CLI binary for .+ not found/; | ||
| const MISSING_CLAUDE_CLI_GUIDANCE = | ||
| "bb could not find the Claude Code CLI on this machine. Install Claude Code (https://claude.com/claude-code), or set BB_CLAUDE_CODE_EXECUTABLE to the full path of the claude binary, then restart bb."; |
There was a problem hiding this comment.
🚨 slopcop/review — The suggested override cannot reach this process
RuntimeProviderProcessManager removes inherited BB_* variables before the bridge starts. The host then adds only PATH. Thus, BB_CLAUDE_CODE_EXECUTABLE=... plus a restart still leaves this value absent.
Pass this supported override into the bridge process. A process-level test should verify the complete path.
There was a problem hiding this comment.
Fixed in ea90e4f: the daemon now forwards BB_CLAUDE_CODE_EXECUTABLE into the runtime shell env, and providerProcessEnvFromShellEnv passes it through the BB_* spawn sanitization to the bridge process.
| const MISSING_CLAUDE_CLI_GUIDANCE = | ||
| "bb could not find the Claude Code CLI on this machine. Install Claude Code (https://claude.com/claude-code), or set BB_CLAUDE_CODE_EXECUTABLE to the full path of the claude binary, then restart bb."; | ||
|
|
||
| function translateMissingClaudeCliError(error: unknown): unknown { |
There was a problem hiding this comment.
🚨 slopcop/review — The error translator does not cover model discovery
model-list.ts calls the SDK query() function directly. It then sends the raw failure to the caller. A missing CLI can fail during model/list, before SdkSession starts.
Share this translator with the model probe. Test the model probe and session paths.
There was a problem hiding this comment.
Fixed in ea90e4f: the translator moved to missing-cli-error.ts and model-list.ts now wraps both the query() call and initializationResult() with it.
|
|
||
| for (const candidate of wellKnownClaudeExecutablePaths(args.env)) { | ||
| try { | ||
| accessSync(candidate, constants.X_OK); |
There was a problem hiding this comment.
🚨 slopcop/review — Implicit paths can cross a privilege boundary
When bb runs with elevated privileges, this code can select a user-controlled HOME binary or a writable global path. The X_OK check also accepts searchable directories. It does not verify the file owner or a symlink target.
Do not use implicit paths during elevated execution. Otherwise, verify a regular file, its resolved target, its owner, and its writable bits.
There was a problem hiding this comment.
Fixed in ea90e4f: well-known locations are skipped when the process runs as root, and all candidates (PATH and well-known) must now be regular files after symlink resolution, not just X_OK. Ownership checks are intentionally omitted: the daemon runs as the user, and the explicit BB_CLAUDE_CODE_EXECUTABLE override remains available for elevated setups.
SawyerHood
left a comment
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
ELI5: bb now looks for Claude in common folders. It also tries to replace a confusing missing-file message with useful instructions.
I found three issues:
- Medium: The suggested
BB_CLAUDE_CODE_EXECUTABLEoverride does not reach the bridge process. The runtime removes inheritedBB_*variables and restores onlyPATH. - Medium: Model discovery calls the SDK directly. It can still show the incorrect SDK reinstall message before a session starts.
- Medium: The new implicit paths can execute an untrusted file when bb runs with elevated privileges. The
X_OKcheck also accepts directories.
The architecture scan found one related mismatch. Host provider status checks only PATH, while the runtime now checks extra paths. One shared, platform-aware resolver would keep these results consistent.
The local probe cost is small. Four failed fixed-path checks took about 12 microseconds. A browser test does not apply because this change only affects the backend bridge.
Validation completed on the exact pull request SHA:
- The
@bb/agent-runtimeTurbo type check passed. - All 831 package tests passed across 43 files.
- A focused run passed 77 bridge and session tests.
git diff --checkpassed.
I added inline comments for the three confirmed issues. I did not use the approve or request-changes review states.
- Forward BB_CLAUDE_CODE_EXECUTABLE from the daemon env into provider processes; spawn sanitization strips BB_* vars, so the documented override never reached the bridge. - Share the missing-CLI error translator with the model probe, which calls the SDK directly and previously surfaced the raw SDK error. - Require executable candidates to be regular files (X_OK alone passes for searchable directories) and skip implicit well-known paths under root. Co-Authored-By: Claude Fable 5 <[email protected]>
The bridge now reports bb guidance instead of the raw SDK "Native CLI binary ... not found" error, so the unavailable-provider match must also accept the new message. Co-Authored-By: Claude Fable 5 <[email protected]>
…rror (get-bb#1177) ## Summary A bb 0.35.1 user hit this error on every Claude turn: > Native CLI binary for darwin-arm64 not found. Reinstall @anthropic-ai/claude-agent-sdk without --omit=optional, or set options.pathToClaudeCodeExecutable. Packaged bb builds inline the Claude Agent SDK into the bridge bundle and do not ship the SDK's native platform package (217 MB per platform), so the SDK's bundled-binary fallback can never work in a shipped install. When the login-shell PATH probe also misses the user's claude install (theirs was at `~/.local/bin/claude`), the session fails with the raw SDK error above. ## Changes - `resolveClaudeCodeExecutable` now checks well-known Claude install locations (`~/.local/bin/claude`, `~/.claude/local/claude`, `/opt/homebrew/bin/claude`, `/usr/local/bin/claude`) when PATH discovery finds nothing. This also benefits model listing, which shares the resolver. - The bridge translates the SDK's "Native CLI binary ... not found" error into bb guidance: install Claude Code, or set `BB_CLAUDE_CODE_EXECUTABLE`, then restart bb. The old message told users to reinstall an npm package they do not own. ## Tests - New test: falls back to well-known install locations when PATH discovery fails. - `pnpm exec turbo run typecheck test --filter=@bb/agent-runtime`: 43 files, 831 tests pass. ## Risks - The well-known-location scan runs only after PATH discovery fails, so existing setups keep their current resolution. - A machine with a stale claude binary at a well-known location could now pick it up where the session previously failed outright; that is strictly better than failing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <[email protected]>
Summary
A bb 0.35.1 user hit this error on every Claude turn:
Packaged bb builds inline the Claude Agent SDK into the bridge bundle and do not ship the SDK's native platform package (217 MB per platform), so the SDK's bundled-binary fallback can never work in a shipped install. When the login-shell PATH probe also misses the user's claude install (theirs was at
~/.local/bin/claude), the session fails with the raw SDK error above.Changes
resolveClaudeCodeExecutablenow checks well-known Claude install locations (~/.local/bin/claude,~/.claude/local/claude,/opt/homebrew/bin/claude,/usr/local/bin/claude) when PATH discovery finds nothing. This also benefits model listing, which shares the resolver.BB_CLAUDE_CODE_EXECUTABLE, then restart bb. The old message told users to reinstall an npm package they do not own.Tests
pnpm exec turbo run typecheck test --filter=@bb/agent-runtime: 43 files, 831 tests pass.Risks
🤖 Generated with Claude Code