fix: show actionable message when Claude Code native binary is missing - #874
Draft
claude[bot] wants to merge 1 commit into
Draft
fix: show actionable message when Claude Code native binary is missing#874claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
The Claude Agent SDK resolves its per-platform native `claude` binary at query() time via `@anthropic-ai/claude-agent-sdk-<platform>` optional dependencies. When that binary isn't present (Sentry WIZARD-CLI-19) — almost always because node_modules was installed on one OS/libc and copied into a different runtime — the SDK threw a raw stack that the wizard relayed verbatim. Detect that failure at the SDK-invocation chokepoint (runAgent's outer catch) and classify it as a new AgentErrorType.NATIVE_BINARY_MISSING, then surface a concise remediation message (reinstall in-place / set pnpm.supportedArchitectures / pass options.pathToClaudeCodeExecutable) through the existing agent-runner error path so both interactive (TUI Outro) and --agent/--ci (NDJSON) modes benefit. The original error is preserved in the log file. Also removes the stale `getClaudeCodeExecutablePath()` cli.js references exposed by the SDK 0.3.x bump: it was log-only in agent-interface.ts, and in mcp-with-fallback.ts it was passed as `claudeCodePath` (a non-existent SDK option name pointing at a file 0.3.x no longer ships), so it was already being ignored — removing it lets the SDK do its own platform-aware resolution. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VMfU7ooAmKSV4U5tXYhXFQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Kaia Peacock · Slack thread
Summary
Two related changes around the Claude Agent SDK's per-platform native
claudebinary.1. Turn the raw "native binary not found" SDK error into an actionable message (primary deliverable).
The SDK (
@anthropic-ai/claude-agent-sdk) resolves its per-platform native binary atquery()time via@anthropic-ai/claude-agent-sdk-<platform>optional dependencies. When that binary isn't present it throws, and the wizard used to relay the raw SDK stack verbatim.Before: the user hit a raw SDK stack —
ReferenceError: Claude Code native binary not found at /app/node_modules/.pnpm/@anthropic-ai+claude-agent-sdk-linux-x64-musl@<ver>/.../claude. Please ensure Claude Code is installed via native installer or specify a valid path with options.pathToClaudeCodeExecutable.— with no explanation of the likely cause or fix.After: a clear, concise message naming the current platform and the most likely cause (cross-OS/libc
node_modulescopy) plus the three fixes:2. Remove the stale
cli.jsbinary-path references exposed by the SDK 0.3.x bump (#872).getClaudeCodeExecutablePath()returned<sdkDir>/cli.js, which@anthropic-ai/claude-agent-sdk0.3.219 no longer ships (onlysdk.mjs+ native binary). Inagent-interface.tsit was log-only. Inmcp-with-fallback.tsit was passed toquery()asclaudeCodePath— but that is not a real SDK option name (the SDK readspathToClaudeCodeExecutable), so the override was already being silently ignored. Removing both lets the SDK do its own platform-aware resolution (the primaryagent-interface.tspath never passed a path and works this way). This is a separate, real bug the 0.3.x bump exposed in the MCP-fallback path; fixing it prevents that path from handing the SDK a dead path.How
src/lib/agent/native-binary-error.ts:isNativeBinaryMissingError()(robust matcher for both SDK message shapes —native binary not found/Native CLI binary for …/pathToClaudeCodeExecutable+not found),describeCurrentPlatform()(<os>-<arch>+ best-effort libc via the Node process report), andformatNativeBinaryMissingMessage().runAgent's outer catch insrc/lib/agent-interface.ts. The error is deterministic and matches no transient-retry pattern, so it re-throws to the outer catch on the first attempt (no retry loop). There it's classified as the newAgentErrorType.NATIVE_BINARY_MISSINGand returned with the remediation message; the raw error is preserved in the log file.src/lib/agent-runner.tsadds a branch that routesNATIVE_BINARY_MISSINGthrough the existingwizardAbort+emitRunErrorpath (taggedrecoverable: 'human_required', exit codeAGENT_FAILED), so both interactive (TUI Outro) and--agent/--ci(NDJSON) modes show the friendly message.NATIVE_BINARY_MISSINGadded to theemitRunErrorcode union inwizard-ui.tsandagent-ui.ts.getClaudeCodeExecutablePath()fromagent-interface.ts(log-only) andmcp-with-fallback.ts(ignoredclaudeCodePathoverride + now-unusedpathimport).Test plan
src/lib/agent/__tests__/native-binary-error.test.ts(7 tests): asserts the friendly message is produced for the representative production WIZARD-CLI-19 error (both message shapes), a bare-string message, non-matching errors, and that all three remediation paths + the platform label appear.pnpm build✅ ·pnpm lint✅ ·pnpm test— only the 35 known-preexistingsrc/utils/__tests__/direct-signup.test.tsfailures (sandbox URL quirk) remain; all other 308 test files (4610 tests) pass, including the new test.Notes
.../claudebinary (the cross-libc install issue), which is a userland install-config problem — this change does not alter platform support; it just makes the failure self-explanatory./reflectchecklist; noted here rather than run.Checklist
pnpm lintandpnpm testpass (only the 35 known-preexistingdirect-signupsandbox failures remain)flows.ts/ navigationstore.tschanges — N/A (no TUI screen/router/store/flow changes)/reflect— noted above as a Claude-authored changeGenerated by Claude Code