[FEATURE] Failed auto-update leaves stale temp directory, blocks reinstall with opaque npm error
Resolved 💬 3 comments Opened Apr 4, 2026 by tlskr Closed Apr 8, 2026
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When the Claude Code auto-updater fails mid-update, it leaves a temporary directory like .claude-code-X3sWxAME in the npm global modules path. Subsequent npm i -g @anthropic-ai/claude-code fails with:
npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/kilroy/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code
npm error dest /Users/kilroy/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/.claude-code-X3sWxAME
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '...' -> '...'
This also means which claude returns nothing — the CLI is completely gone, not just broken.
Environment: macOS, Node v24.12.0 via nvm, npm global install
Issue written up by Claude, Opus 4.6
Proposed Solution
The fix is rm -rf .../.claude-code-* then reinstall, but nothing in the error message suggests that. A user who isn't deeply familiar with npm internals would be stuck.
Suggestions:
- The auto-updater should clean up its own temp directories on failure (or on next startup)
- If a stale temp dir is detected during install, the installer could remove it automatically or at least print: "A previous update left a temporary directory. Run
rm -rf <path>and retry." - Consider a
claude doctororclaude repaircommand that detects and fixes common broken states
Alternative Solutions
_No response_
Priority
Low - Nice to have
Feature Category
Other
Use Case Example
> which claude
failed on my command line because of this
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗