[BUG] claude doctor reports insufficient permissions for automatic updates when using NVM

Status Fixed / completed
Maintainer reply None cached
Activity 12 comments · opened Mar 12, 2025 · closed Aug 6, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 0.2.37
  • Operating System: macOS 15.3.1
  • Terminal: iTerm2

Bug Description

I use NVM on mac. NVM sets up my global prefix as a directory that my user owns, under my home DIR:

$ npm prefix -g
/Users/bburns/.nvm/versions/node/v22.13.1
$ ls -al $(npm prefix -g)
total 1248
drwxr-xr-x@  9 bburns  staff     288 Jan 29 17:41 .
drwxr-xr-x@  7 bburns  staff     224 Feb 21 13:04 ..
-rw-r--r--@  1 bburns  staff  454231 Jan 21 14:38 CHANGELOG.md
-rw-r--r--@  1 bburns  staff  140397 Jan 21 14:38 LICENSE
-rw-r--r--@  1 bburns  staff   39769 Jan 21 14:38 README.md
drwxr-xr-x@ 18 bburns  staff     576 Mar 12 18:51 bin
drwxr-xr-x@  3 bburns  staff      96 Jan 21 14:38 include
drwxr-xr-x@  3 bburns  staff      96 Jan 21 14:38 lib
drwxr-xr-x@  4 bburns  staff     128 Jan 21 14:38 share

This is a standard NVM setup on mac, designed to avoid the user having to use sudo when doing global installs.

In spite of this, running claude doctor reports Claude Code can't update itself because it doesn't have sufficient permissions.

Steps to Reproduce

  1. Set up node using NVM
  2. Run npm install -g @anthropic-ai/claude-code
  3. Run claude doctor

Expected Behavior

It wouldn't complain about update permissions.

Actual Behavior

It complains about update permissions.

Additional Context

<img width="1728" alt="Image" src="https://github.com/user-attachments/assets/5b19aed9-f522-4adb-a58a-33d432da19c1" />

View original on GitHub ↗

12 Comments

mceachen · 1 year ago

I've been able to reproduce this same symptom on Ubuntu 24.04.

I've followed your instructions exactly for a local npm prefix.

It shouldn't matter, but I've tried with apt-installed nodejs, nvm-installed node, and fvm-installed node, and tried with node v20.19.0 and v22.14.0, using npm v11.2.0.

One suggestion: claude --debug doctor emits no debug logging. You might want to emit what directory and what mode bits you think aren't correct, just to help your own engineers track down this issue.

zachblume · 1 year ago

reproduced on mac 15.3.1 (24D70) with:
❯ nvm --version
0.40.1
❯ node --version
v20.14.0

I tried setting the entire .nvm dir and subdirs to be user writeable and reinstalling but that did nothing. Hmm

ichoosetoaccept · 1 year ago

Happens to me as well on macOS 15.3.2.

Following Anthropic's own recommended solution does not fix it.

varun-d · 1 year ago

Same! I have tried sudo but that wasn't the right idea to go with.

Claude warning: "✗ Auto-update failed · Try claude doctor or npm i -g @anthropic-ai/claude-code"

Reproduced on Mac OS 15.5 (24F74)

❯ nvm --version
0.39.7

❯ node --version
v23.10.0

❯ claude --version
1.0.39 (Claude Code)

benjamincburns · 1 year ago

Not sure if I should close this, as others are still apparently experiencing this issue, but I no longer experience this problem.

Unfortunately I don't have the same laptop where this was originally happening to test, but I do still run claude code on a mac that uses an essentially identical setup (NVM, same dotfiles, etc). I just found that claude doctor no longer gives me this error. This was on v1.0.35 installed into my current NVM default node version's global NPM prefix.

<img width="629" alt="Image" src="https://github.com/user-attachments/assets/514878fb-57dc-4566-b30b-e8fe2010b815" />

As you can see in the above screenshot, it also advised me to run /migrate-installer in a normal claude session to migrate my claude installation to ~/.claude/local and enable automatic updates. That sort of install is preferable to me, so I did that. In the process it updated to v1.0.41, and claude doctor seems happy now. 👇

<img width="649" alt="Image" src="https://github.com/user-attachments/assets/0c3b4f24-03c5-4be0-adc3-6be55238547b" />

Note that you'll need to run source ~/.zprofile or close/reopen your terminal session to get the claude command to work after the installer migration. Unfortunately it doesn't (can't?) add the claude alias that it creates to your current terminal session automatically.

I'll leave this open for now, but if others report a similar sequence of events fixes this for them, and nobody seems to be reporting that they're still having this issue, I'm happy to close.

varun-d · 1 year ago

@benjamincburns thank you that worked. Small correction to your final step tho.

After all the steps refresh terminal:
source ~/.zshrc

Key steps.

  1. Stop running Claude Code (exit)
  2. /migrate-installer
  3. Confirm install to ~/.claude/local
  4. run source ~/.zshrc or your appropriate terminal reload (bash, etc)
  5. [OPTIONAL] You can set autoUpdates to true: claude config set -g autoUpdates true
TheITVeteran · 1 year ago

I still have this issue (not a dev so forgive me if I miss something obvious).

Used ChatGPT to help diagnose the problem. Turns out on my Mac there is nothing wrong with the file/folder permissions per se, but the update (from within claude itself) still fails.

  • Checked npm prefix -g ( /opt/homebew )
  • Checked ls -al $(npm prefix -g) : all stated I had RW permission
  • Checked the link ( ls -l /opt/homebrew/bin/claude ) : I had permission to the lib/modules/etc.
  • Ran the suggested chown command but didn't help.

Was on version CC 1.0.64.
MAC 15.5 M4 Air
npm 11.5.2
node 24.4.1

--

Running this manually worked:

npm update -g @anthropic-ai/claude-code --loglevel verbose

However the issue of doing this via CC persists:

% claude update
Current version: 1.0.65
Checking for updates...

Warning: Insufficient permissions for auto-updates
Fix: Run: sudo chown -R $USER:$(id -gn) $(npm -g config get prefix)or use claude migrate-installer to migrate to local installation
Claude Code is up to date (1.0.65)

--

I assume running it via sudo would work as would moving it locally but didn't try.

rdrcode · 1 year ago

In order to fix missing privileges of a global installation, claude doctor asked me to run the following command, which could result in severe system damage:

sudo chown -R $(id -gn) $(npm -g config get prefix)

Because npm -g config get prefix resolves to /usr, this command recursively changes ownership of the entire /usr directory to the user's primary group. This breaks critical system functionality and renderes sudo, pkexec, and other tools unusable.

System:
OS: Ubuntu 22.04 LTS
Node.js: v20.19.4
npm: 10.8.2
npm prefix: /usr

benjamincburns · 1 year ago

@rdrcode I think you should open a new issue for that, as it's distinctly different from the one I describe in my original post above. Your issue looks to be similar to the issue that @TheITVeteran is having.

Given that I'm not seeing any new reports of the same issue that I had originally, I'm going to close this so I stop getting notifications about unrelated things.

ridafkih · 1 year ago

This is still an issue, but for anyone encountering this - you can install native and it should resolve it. Using the built-in command to migrate to the native installation _will silently fail_ if you attempt it (specifically speaking, Claude uninstalls itself and leaves it at that), so just uninstall it globally and reinstall it natively.

  1. Uninstall any local versions of @anthropic-ai/claude-code
  2. Uninstall any global versions of the package.
npm uninstall -g @anthropic-ai/claude-code
  1. Once you're done, you may install it globally.
curl -fsSL https://claude.ai/install.sh | bash
  1. Open a new terminal, and run claude doctor to check the output.
claude doctor

Full Run-Through

❯ claude doctor

 Diagnostics
 └ Currently running: npm-global (1.0.72)
 └ Path: /Users/ridafkih/.nvm/versions/node/v24.3.0/bin/node
 └ Invoked: /Users/ridafkih/.nvm/versions/node/v24.3.0/bin/claude
 └ Config install method: local
 └ Auto-updates enabled: true
 └ Update permissions: No (requires sudo)
 Warning: Insufficient permissions for auto-updates
 Fix: Run: sudo chown -R $USER:$(id -gn) $(npm -g config get prefix)or use
 `claude migrate-installer` to migrate to local installation

 Agent Configurations
 └ Loaded custom agents: 0

 Press Enter to continue…
~ via 🐹 v1.23.4 via  v24.3.0 via 💎 v3.4.3 via 🐦 v6.1.2 took 2s 
❯ npm uninstall -g @anthropic-ai/claude-code

removed 3 packages in 260ms
~ via 🐹 v1.23.4 via  v24.3.0 via 💎 v3.4.3 via 🐦 v6.1.2 
❯ curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code...

✔  Claude Code successfully installed!

  Version: 1.0.72

  Location: ~/.local/bin/claude


  Next: Run claude --help to get started

✅ Installation complete!

_In a new terminal..._

~ via 🐹 v1.23.4 via  v24.3.0 via 💎 v3.4.3 via 🐦 v6.1.2 took 7s 
❯ claude doctor

 Diagnostics
 └ Currently running: native (1.0.72)
 └ Path: /Users/ridafkih/.local/bin/claude
 └ Invoked: /$bunfs/root/claude
 └ Config install method: native
 └ Auto-updates enabled: true

 Agent Configurations
 └ Loaded custom agents: 0

 Press Enter to continue…
drichar · 1 year ago

If you have Bun installed, here is a detailed analysis and a workaround that resolved the issue for me: https://github.com/anthropics/claude-code/issues/3980#issuecomment-3092423248

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.