Background auto-updater leaves native binary broken after failed update

Status Open
Reported on v2.1.237
Maintainer reply None cached
Activity 0 comments · opened Aug 31, 2026

Description

The background auto-updater (npm-global install path, macOS darwin-arm64) failed twice within about 1.5 weeks while attempting minor-version bumps, and each time left the CLI completely broken with:

Error: claude native binary not installed.

Either postinstall did not run (--ignore-scripts, some pnpm configs)
or the platform-native optional dependency was not downloaded
(--omit=optional).

Root cause (as far as I could tell)

~/.claude/.last-update-result.json recorded both failures:

{"timestamp":"2026-08-21T06:08:09.512Z","path":"npm-global","outcome":"failed","status":"install_failed","version_from":"2.1.237","version_to":"2.1.238","error_code":null}
{"timestamp":"2026-08-31T06:24:03.903Z","path":"npm-global","outcome":"failed","status":"install_failed","version_from":"2.1.250","version_to":"2.1.251","error_code":null}

In both cases, the package metadata (package.json, install.cjs, etc. in @anthropic-ai/claude-code) had already been updated to the new target version, but the platform-specific optional dependency (@anthropic-ai/claude-code-darwin-arm64) was never fetched/installed, and bin/claude.exe was left as the small placeholder stub script (~500 bytes) whose only content is that error message, instead of the real binary.

This looks like the updater writes/updates package metadata before confirming the platform-native optional dependency actually downloaded and got copied into bin/claude.exe — so a failure partway through the update leaves a self-inconsistent, unusable install rather than rolling back to the previous working version.

Workaround

cd <global-node_modules>/@anthropic-ai/claude-code
npm install @anthropic-ai/claude-code-darwin-arm64@<target-version> --no-save
node install.cjs

This re-fetches the missing native package and reruns the postinstall step that copies the real binary over the stub.

Suggested fix

  • Have the auto-updater verify the native binary was successfully copied into bin/claude.exe before considering the update complete / before overwriting the previous working package.json.
  • On failure, roll back to the last known-good binary rather than leaving a mixed-version, broken state.
  • The error message itself (postinstall did not run ... or optional dependency wasn't downloaded) is misleading in this scenario, since neither --ignore-scripts nor --omit=optional was in play — it was a background auto-update failure. A distinct message/diagnostic for this case would help users self-diagnose faster.

Environment

  • macOS (darwin-arm64), Node via nvm
  • Install path: npm-global
  • Versions affected: update attempts 2.1.237→2.1.238 and 2.1.250→2.1.251 (2026-08-21 and 2026-08-31)

----

^ I let the Claude app for MacOS fix Claude code installs, and generate the above issue text

View original on GitHub ↗