Auto-update fails repeatedly with ENOTEMPTY error on macOS with nvm
Open 💬 4 comments Opened Nov 20, 2025 by david-gethers-cityblock
Environment
- OS: macOS (Darwin 24.6.0)
- Node Version: v22.10.0
- npm Version: 10.9.0
- Node Manager: nvm
- Claude Code Version: 2.0.46 → 2.0.47 (failing to update)
- Installation Path:
~/.nvm/versions/node/v22.10.0/lib/node_modules/@anthropic-ai/claude-code
Description
Claude Code's auto-update mechanism repeatedly fails with an ENOTEMPTY error when attempting to update from version 2.0.46 to 2.0.47. Each failed update leaves behind a stale temporary directory (.claude-code-euxhxob3), which prevents all subsequent auto-update attempts from succeeding.
This results in the constant error message: **"auto-update failed try claude doctor"*
Error Message
npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/[username]/.nvm/versions/node/v22.10.0/lib/node_modules/@anthropic-ai/claude-code
npm error dest /Users/[username]/.nvm/versions/node/v22.10.0/lib/node_modules/@anthropic-ai/.claude-code-euxhxob3
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '.../@anthropic-ai/claude-code' -> '.../@anthropic-ai/.claude-code-euxhxob3'
Reproduction Steps
- Install Claude Code via npm on macOS with nvm
- Launch Claude Code (which triggers auto-update check)
- When a new version is available, the auto-updater attempts to update in the background
- The update fails, leaving a
.claude-code-*temp directory - All subsequent auto-update attempts fail with ENOTEMPTY error
- User sees "auto-update failed * try claude doctor" message constantly
Root Cause Analysis
- npm's atomic update strategy tries to rename the existing installation to a temp directory
- The temp directory name appears to be static/deterministic (
.claude-code-euxhxob3) - When the first update fails, the temp directory persists
- Subsequent attempts try to use the same temp directory name, resulting in ENOTEMPTY
- Contributing factors:
- macOS extended attributes (
com.apple.provenance) on the installation - Large installation size (90MB)
- Possible file handles from running Claude Code process
- npm's atomic rename operation failing mid-transaction
Workaround
# Remove stale temp directory
rm -rf ~/.nvm/versions/node/*/lib/node_modules/@anthropic-ai/.claude-code-*
# Update manually
npm update -g @anthropic-ai/claude-code
# Or disable auto-updates
export DISABLE_AUTOUPDATER=1
Suggested Fixes
- Use unique temp directory names (timestamp-based) instead of static names
- Clean up stale temp directories before attempting update
- Add error handling to retry with a different temp directory name if ENOTEMPTY occurs
- Gracefully degrade by notifying user and suggesting manual update instead of repeatedly failing silently
- Check for running processes before attempting update
Impact
- User constantly sees "auto-update failed" error messages
- Auto-update mechanism becomes permanently broken until manual intervention
- Likely affects nvm users on macOS (and possibly other Node version managers)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗