Auto-updater crashes and corrupts installation, leaving claude command broken
Problem
The npm auto-updater frequently crashes mid-update, leaving the global installation in a broken state:
- Auto-update triggers during normal usage
- It deletes the current installation
- The install of the new version fails or gets interrupted
claudecommand is now gone — the binary was deleted but nothing replaced it- Running
npm install -g @anthropic-ai/claude-codeafter this sometimes creates duplicates or hits permission errors because npm still has a ghost entry for the old install
This has happened multiple times. The result is being locked out of Claude Code until manually cleaning up node_modules and reinstalling.
Expected behavior
The auto-updater should be atomic: download the new version fully to a temp location, verify it, then swap the symlink. If anything fails, the old version should remain intact and functional. The current approach of delete-then-install is inherently fragile.
Current workarounds (all have drawbacks)
- Disable auto-update (
CLAUDE_CODE_DISABLE_AUTO_UPDATE=1) — works but then you have to manually update, defeating the purpose - Use brew — atomic upgrades but always days behind npm releases
- Use npx — has its own caching/version resolution bugs
Environment
- macOS (Darwin)
- Node.js installed via standard methods
- npm global install (
npm install -g @anthropic-ai/claude-code)
Suggestion
Implement atomic updates — download new version to a staging directory, verify integrity, then atomically replace the old version. If the download or verification fails, keep the existing working installation. This is how tools like Volta, Rustup, and Homebrew handle updates.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗