fix(install): fall back to SDK bundled binary when install.sh produces no binary#1260
Open
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
Open
fix(install): fall back to SDK bundled binary when install.sh produces no binary#1260MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
Conversation
…s no binary
When claude.ai is unreachable (corporate firewall, air-gapped runner),
the curl|bash install pipeline can exit 0 without producing a binary at
$HOME/.local/bin/claude. The current code returns that bogus path to the
Agent SDK, which then crashes with 'Claude Code native binary not found'.
This change verifies the binary actually exists on disk before returning
its path. When missing, it returns undefined so the Agent SDK falls back
to its bundled platform binary (the @anthropic-ai/claude-agent-sdk-{platform}
optional dependency) — restoring the v1.0.99 behavior.
Closes anthropics#1242
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.
Why
Closes #1242. v1.0.100 broke any environment where
claude.aiis unreachable: corporate firewalls, air-gapped GitHub Enterprise runners, etc. Thecurl ... | bashinstall pipeline can exit 0 even when curl itself fails (noset -o pipefail), so we end up handing a non-existent path to the Agent SDK, which crashes withReferenceError: Claude Code native binary not found. v1.0.99 worked here because the SDK's bundled platform binary (@anthropic-ai/claude-agent-sdk-{platform}optional dep) was still picked up.What
installClaudeCode()now returnsstring | undefined:resolveInstalledClaudeBinary()helper that checksexistsSyncbefore returning the path.undefined, letting the SDK fall back to its bundled binary.undefinedfor the same fallback path.PATH_TO_CLAUDE_CODE_EXECUTABLEand downstream callers continue to work; only the unannotated success-with-empty-binary case changes.Tested
test/resolve-installed-claude-binary.test.ts: covers (a) binary present → returns path, no warn; (b) binary missing → returnsundefinedand warns once.exported for the unit; the call site still passes the samehomeBinvalue).