[BUG]
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
A background auto-update appears to have run unprompted on macOS and broke the install. Afterwards claude failed with:
zsh: permission denied: claude
which claude returned claude not found while running claude returned permission denied (stale shell hash). After hash -r, the cause became visible: the global bin symlink pointed to a Windows binary:
.../bin/claude -> ../lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe
The package bin/ directory contained only claude.exe, sized just 500 bytes — too small to be a valid launcher, suggesting a truncated/corrupt write. No macOS launcher (extension-less binary or cli.js) was present at all, so every invocation hit permission denied.
File timestamps (22:02 and 22:16 local) matched the suspected auto-update window. No manual update was triggered.
Recovery was also blocked
Both npm uninstall -g and npm install -g failed:
npm error code ENOTEMPTY
npm error syscall rename
ENOTEMPTY: directory not empty, rename
'.../@anthropic-ai/claude-code' -> '.../@anthropic-ai/.claude-code-<hash>'
The failed auto-update left the package directory in an inconsistent state that blocked npm from replacing it.
Workaround that fixed it
rm -rf <prefix>/lib/node_modules/@anthropic-ai/claude-code
rm -rf <prefix>/lib/node_modules/@anthropic-ai/.claude-code-<hash>
npm install -g @anthropic-ai/claude-code
hash -r
After this, the symlink resolved correctly and claude --version returned 2.1.160.
Environment
- Platform: macOS (Apple Silicon, MacBook Air)
- Node: v22.19.0 (installed via nvm)
- Install method: global npm (
npm install -g @anthropic-ai/claude-code) - Shell: zsh
- Version after recovery: 2.1.160
Suggested areas to investigate
- Platform detection in the auto-updater (why a Windows
.exewas selected/written on macOS) - The 500-byte truncated binary (incomplete download/write?)
- Auto-update leaving the package dir non-empty in a way that blocks subsequent npm operations — standard uninstall/reinstall could not recover it, which most users won't know how to fix manually
What Should Happen?
Autoupdate should have worked, an Clude code should have worked when trying to launch a new session
Error Messages/Logs
Steps to Reproduce
I can't be sure how to reproduce this, I just happened, and I thought you wanted to know
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.160
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗