claude-code - 💡(How to fix) Fix /doctor falsely reports native install as 'leftover npm global installation' when npm prefix is ~/.local [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56256Fetched 2026-05-06 06:33:01
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

/doctor reports Leftover npm global installation at ~/.local/bin/claude and suggests npm -g uninstall @anthropic-ai/claude-code, but the binary at that path is the active native installation, not an npm leftover. Running the suggested command is a no-op (npm has no such package installed) and, if a user follows up by deleting the symlink manually, it breaks their working install.

Root Cause

/doctor reports Leftover npm global installation at ~/.local/bin/claude and suggests npm -g uninstall @anthropic-ai/claude-code, but the binary at that path is the active native installation, not an npm leftover. Running the suggested command is a no-op (npm has no such package installed) and, if a user follows up by deleting the symlink manually, it breaks their working install.

Code Example

$ npm ls -g @anthropic-ai/claude-code
/home/<user>/.local/lib
└── (empty)

---

$ ls -la ~/.local/bin/claude
lrwxrwxrwx ... /home/<user>/.local/bin/claude -> /home/<user>/.local/share/claude/versions/2.1.128

$ file ~/.local/share/claude/versions/2.1.128
ELF 64-bit LSB executable, x86-64, ... dynamically linked

$ npm config get prefix
/home/<user>/.local

$ npm root -g
/home/<user>/.local/lib/node_modules
RAW_BUFFERClick to expand / collapse

Title: /doctor falsely reports native install as "leftover npm global installation" when npm prefix is ~/.local

Version: Claude Code 2.1.128 (native installer, Linux x86_64)

This bug report was drafted by Claude Code on behalf of the reporter, based on diagnostic commands run in the user's shell. The reporter reviewed it before filing.

Summary

/doctor reports Leftover npm global installation at ~/.local/bin/claude and suggests npm -g uninstall @anthropic-ai/claude-code, but the binary at that path is the active native installation, not an npm leftover. Running the suggested command is a no-op (npm has no such package installed) and, if a user follows up by deleting the symlink manually, it breaks their working install.

Environment

  • OS: Linux 6.8.0-107-generic (Ubuntu)
  • Shell: bash
  • Install method: native installer (~/.local/share/claude/versions/<ver>)
  • npm config: prefix = /home/<user>/.local — npm and the native installer share the same bin directory. This is a common setup to avoid sudo for global npm installs.

Steps to reproduce

  1. npm config set prefix ~/.local (or have it set this way already).
  2. Install Claude Code via the native installer (not npm). Result: ~/.local/bin/claude is a symlink to ~/.local/share/claude/versions/<ver> (an ELF binary).
  3. Run /doctor.

Expected

Doctor recognizes a native install (symlink target lives under ~/.local/share/claude/versions/) and does not flag it.

Actual

Leftover npm global installation at /home/<user>/.local/bin/claude Suggested fix: Run: npm -g uninstall @anthropic-ai/claude-code

The npm package is not actually installed:

$ npm ls -g @anthropic-ai/claude-code
/home/<user>/.local/lib
└── (empty)

Diagnostic output

$ ls -la ~/.local/bin/claude
lrwxrwxrwx ... /home/<user>/.local/bin/claude -> /home/<user>/.local/share/claude/versions/2.1.128

$ file ~/.local/share/claude/versions/2.1.128
ELF 64-bit LSB executable, x86-64, ... dynamically linked

$ npm config get prefix
/home/<user>/.local

$ npm root -g
/home/<user>/.local/lib/node_modules

Suggested fix

Before flagging <bin>/claude as an npm leftover, resolve the symlink and check whether the target lives under <npm root -g>/@anthropic-ai/claude-code/ (npm-managed) versus <XDG_DATA_HOME>/claude/versions/ (native-managed). Equivalent quick check: only flag as npm leftover if npm ls -g @anthropic-ai/claude-code actually lists the package.

Impact

  • Confusing for users on the common npm prefix=~/.local setup.
  • Suggested command is a no-op.
  • A user who escalates to rm the symlink based on the wording will break their working installation.

extent analysis

TL;DR

The /doctor command should be updated to correctly identify native installations by resolving symlinks and checking the target path.

Guidance

  • Before flagging a binary as an npm leftover, resolve the symlink and check whether the target lives under the npm-managed directory or the native-managed directory.
  • Use npm ls -g @anthropic-ai/claude-code to verify if the package is actually installed via npm.
  • Update the /doctor command to perform this check to avoid false positives.
  • Consider adding a check for the XDG_DATA_HOME environment variable to determine the native-managed directory.

Example

No code snippet is provided as the issue is related to the logic of the /doctor command, which is not explicitly shown in the issue body.

Notes

The issue is specific to the npm prefix=~/.local setup, which is a common configuration to avoid using sudo for global npm installs. The suggested fix should be applied to the /doctor command to correctly identify native installations.

Recommendation

Apply a workaround by modifying the /doctor command to resolve symlinks and check the target path before flagging a binary as an npm leftover, as this will correctly identify native installations and avoid false positives.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix /doctor falsely reports native install as 'leftover npm global installation' when npm prefix is ~/.local [1 comments, 2 participants]