[BUG] ✗ Auto-update failed · Try claude doctor or npm i -g @anthropic-ai/claude-code
Open 💬 18 comments Opened May 7, 2025 by walt93
Environment
- Platform (select one):
- [√ Anthropic API
- Claude CLI version: 0.2.61 (Claude Code)
- Operating System: Mac OS 15.3
- Terminal: IntelJIdea 2023.1.1
Bug Description
Auto update does not work.
Specified instructions for update do not work.
Only solution has been to completely delete the claude code directory.
Steps to Reproduce
- Run Claude Code
- Observe that it can't update itself
- Try to update it with "npm i -g @anthropic-ai/claude-code"
- Observe it fail:
% npm i -g @anthropic-ai/claude-code
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/walt/.nvm/versions/node/v18.18.0/lib/node_modules/@anthropic-ai/claude-code
npm ERR! dest /Users/walt/.nvm/versions/node/v18.18.0/lib/node_modules/@anthropic-ai/.claude-code-Mnsj2ANr
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/walt/.nvm/versions/node/v18.18.0/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/walt/.nvm/versions/node/v18.18.0/lib/node_modules/@anthropic-ai/.claude-code-Mnsj2ANr'
npm ERR! A complete log of this run can be found in: /Users/walt/.npm/_logs/2025-05-07T21_04_49_796Z-debug-0.log
- Try the suggested "claude doctor" and observe as it think it succeeds:
% claude doctor
✓ npm permissions: OK
Your installation is healthy and ready for auto-updates.
You can also install Claude Code locally to avoid npm permission issues using the slash command:
/migrate-installer
Press Enter to continue…
Expected Behavior
The update to work
Actual Behavior
The update failed
Additional Context
<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
18 Comments
I received the same error message today and now claude won't run at all.
claude doctorresults in the same error.This looks more like a known npm error rather than a Claude Code issue. The ENOTEMPTY error occurs when npm fails to clean up temporary directories during package updates.
What's happening:
.claude-code-jtqndIsa) during the update processEvidence:
ENOTEMPTY: directory not empty, rename ...Solution:
Remove the leftover temporary directory:
For Windows users:
Replace the paths with your npm global directory (check with npm config get prefix).
This workaround resolves the immediate issue, but the underlying npm bug remains unfixed.
@liby this answer worked for me, thank you!
I used /migrate-installer which seemed to work - I interrogated the problem with claude and ut said the error occurs because npm can't rename the existing claude-code directory during the update process. You can set up a local installation that avoids these npm global installation conflicts:
The "/migrate-installer" from claude code as it seems to be Anthropic's recommended solution for avoiding these npm-related update issues.
This is happening everyday and results in
command not found: claudeYour auto-updates are breaking claude. Stop it.
can't even disable auto updates :(
<img width="1298" height="387" alt="Image" src="https://github.com/user-attachments/assets/f27b1e94-d3b9-45bb-b3de-ff2479d8e388" />
I am having the same issue, and was contacting the Anthropic help - the chatbot, which it gave me the following suggestions
<img width="549" height="513" alt="Image" src="https://github.com/user-attachments/assets/9b95b137-4eb1-49b0-9e24-90d5be608ca1" />
however, when i was using the usual VS code plugin, the claude code command box is still showing the "auto-update failed, try claude doctor or npm i -g @anthropic-ai/claude-code
now my actual questions are
<img width="556" height="216" alt="Image" src="https://github.com/user-attachments/assets/1bd7bd5a-a892-4b9f-a1ae-d55fcf1314c7" />
anyone knows what is the difference between the local install under the ./local/share/claude versus the npm global installation?
hi! for me, i faced the same error but my claude works fine, just an annoying notification that i treat.
I sovled it by using sudo to repeat the installation command again as certain npm installation steps required root access, this is probably not the best way though.
The solution posted by @liby worked for me - but because I was using nvm, the dir that needed removing was elsewhere. Found it like this:
After removing the one with a dot prefix, auto-update finally works again!
for my case, i use the VS code with Claude Code plug in,
it used to be - when VS code prompted me there is an update for claude code, i will let it run on "auto-update"
but now - i have to manually remove the folder - /Users/hwee/.nvm/versions/node/v23.11.0/bin/claude
then run the npm update instruction. it is particularly annoying when i need to perform manual step. anyone knows what is the permenent solution?
A generic copy-pastable version of @liby's solution that would also work for most other setups like @iwootten's is:
@joelbeedle thanks a lot for the steps, i tried and it works!
For me problem was with a permission and it works this way:
Install without sudo by changing global prefix
If you don’t want to use sudo, configure npm to install globals into your home directory:
Tip: You can add that last export line into ~/.bashrc or ~/.zshrc.
Now reinstall again:
sudo npm remove -g @anthropic-ai/claude-code@joelbeedle steps:
ls -la "$(npm prefix -g)/lib/node_modules/@anthropic-ai" | grep clauderm -rf "$(npm prefix -g)/lib/node_modules/@anthropic-ai/.claude-code-"*npm install -g @anthropic-ai/claude-code@latestfix works, but next auto-update will fail again for me.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Adding a data point: this fires deterministically under a non-root TUI user when the package was installed by root (or by a different system user).
Setup: claude-code v2.1.121 installed by
claude-coord:claude-coordat/opt/claude-runtime/nvm/versions/node/v22.22.1/lib/node_modules/@anthropic-ai/claude-code/. Mode0755. We launch multiple lane TUIs via arunuser-based wrapper that drops to per-lane users (uid 9001-9005).On startup, the TUI auto-update runs
npm install --global @anthropic-ai/claude-code. npm tries to atomically swap the existing version's directory:Lane user (
uid 9003) cannot rename in a directory owned byclaude-coord:claude-coord. The TUI proceeds with the existing installed version (so functionality isn't blocked), but emits the✗ Auto-update failedbanner on every launch. Lane sessions stay on whatever version was last claude-coord-installed, while root sessions auto-update past it. Long-running version drift between users on the same machine.This is distinct from the OP's macOS
ENOTEMPTYcase, but shares the same root cause class: the auto-update path doesn't account for the running user not owning the package install directory.Possible mitigations the maintainers might consider:
npm i -gwhich will also failDISABLE_AUTOUPDATER=1or--no-update-checkflag so multi-user setups can opt out cleanly$XDG_CACHE_HOME/claude-code/or similar) when the system install isn't user-writableWe've worked around this by accepting the version drift in our architecture; documenting the case in case it helps prioritize one of the above.
M1 Mac MacOS Tahoe 26.3 (25D125) node v22.18.0Had a bunch of sessions open, did not notice
✗ Auto-update failedon one of them and started new shell, had to reinstall in the end.