Skip to content

Find Claude CLI in well-known locations and clarify the missing-CLI error - #1177

Merged
SawyerHood merged 3 commits into
mainfrom
bb/thr_dkd9n45gvk
Aug 8, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
bb/thr_dkd9n45gvk

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

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

…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]>
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 SawyerHood left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🚨 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_EXECUTABLE override does not reach the bridge process. The runtime removes inherited BB_* variables and restores only PATH.
  • 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_OK check 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-runtime Turbo type check passed.
  • All 831 package tests passed across 43 files.
  • A focused run passed 77 bridge and session tests.
  • git diff --check passed.

I added inline comments for the three confirmed issues. I did not use the approve or request-changes review states.

SawyerHood and others added 2 commits August 7, 2026 19:48
- 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]>
@SawyerHood
SawyerHood merged commit 7a88c9f into main Aug 8, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/thr_dkd9n45gvk branch August 8, 2026 02:58
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
…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]>
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