Skip to content

fix(install): fall back to SDK bundled binary when install.sh produces no binary#1260

Open
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:fix/claude-ai-unreachable-fallback
Open

fix(install): fall back to SDK bundled binary when install.sh produces no binary#1260
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:fix/claude-ai-unreachable-fallback

Conversation

@MukundaKatta
Copy link
Copy Markdown

Why

Closes #1242. v1.0.100 broke any environment where claude.ai is unreachable: corporate firewalls, air-gapped GitHub Enterprise runners, etc. The curl ... | bash install pipeline can exit 0 even when curl itself fails (no set -o pipefail), so we end up handing a non-existent path to the Agent SDK, which crashes with ReferenceError: 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 returns string | undefined:

  • Pulled the path-resolve logic into an exported resolveInstalledClaudeBinary() helper that checks existsSync before returning the path.
  • When the binary is missing on disk, it logs a clear warning explaining the likely cause (firewall / air-gapped) and returns undefined, letting the SDK fall back to its bundled binary.
  • After 3 install failures, we no longer throw — we log loudly and return undefined for the same fallback path.
  • PATH_TO_CLAUDE_CODE_EXECUTABLE and downstream callers continue to work; only the unannotated success-with-empty-binary case changes.

Tested

  • New test/resolve-installed-claude-binary.test.ts: covers (a) binary present → returns path, no warn; (b) binary missing → returns undefined and warns once.
  • Existing tests unaffected (the helper is exported for the unit; the call site still passes the same homeBin value).

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

v1.0.100 breaks environments where claude.ai is unreachable (install.sh silently fails, SDK bundled binary bypassed)

1 participant