[BUG] doctor misclassifies an npm installation at ~/.local/bin/claude as native
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
doctor identifies the running installation as npm-global, then lists that same installation as native. Both installations in the reproduction are npm-global and resolve to distinct package files.
This affects npm launchers at ~/.local/bin/claude, including installs with npm prefix ~/.local. The list appears when at least two candidates are found; even one installation can be counted twice. Both copies run successfully, and the report ends with No installation issues found.
What Should Happen?
Both entries should be npm-global. Classify candidates by the installation they belong to, deduplicate resolved targets, and include the running executable regardless of npm prefix. Deduplication alone cannot fix this reproduction because the targets are different.
Error Messages/Logs
Running: npm-global (2.1.270)
Path: /Users/me/.local/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe
Config install method: global
Multiple installations found
- npm-global at /tmp/cc-repro/prefix/bin/claude
- native at /Users/me/.local/bin/claude
Steps to Reproduce
Requires Node.js 22+ and npm. Run in the same shell; commands leave the configured npm prefix unchanged.
- Install the first copy under
~/.local(skip if this version is already there):
``sh``
npm_config_prefix="$HOME/.local" npm install -g @anthropic-ai/claude-code@2.1.270
The resulting launcher is an npm symlink:
``text``
~/.local/bin/claude -> ../lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe
- Run it with the npm prefix still at
~/.local. One installation fills both candidate slots, so the same path is listed twice, once per type:
``sh``
npm_config_prefix="$HOME/.local" ~/.local/bin/claude doctor
```text
Multiple installations found
- npm-global at /Users/me/.local/bin/claude
- native at /Users/me/.local/bin/claude
```
- Install a second copy at a separate prefix:
``sh``
CC_REPRO=$(mktemp -d /tmp/cc-repro.XXXXXX)
npm_config_prefix="$CC_REPRO/prefix" npm_config_cache="$CC_REPRO/cache" \
npm install -g @anthropic-ai/claude-code@2.1.270
- Run the original. Its header says npm-global; its entry in the list says native:
``sh``
npm_config_prefix="$CC_REPRO/prefix" ~/.local/bin/claude doctor
- Optional: demonstrate the same enumeration omitting the running installation:
``sh``
npm_config_prefix="$CC_REPRO/alt-prefix" npm_config_cache="$CC_REPRO/cache" \
npm install -g @anthropic-ai/claude-code@2.1.270
npm_config_prefix="$CC_REPRO/alt-prefix" "$CC_REPRO/prefix/bin/claude" doctor
Only alt-prefix/bin/claude (npm-global) and ~/.local/bin/claude (native) appear. The running prefix/bin/claude is omitted.
- Remove the temporary copies:
``sh``
rm -rf -- "${CC_REPRO:?}" && unset CC_REPRO
The ~/.local installation remains. Remove it too if step 1 installed it:
``sh``
npm_config_prefix="$HOME/.local" npm uninstall -g @anthropic-ai/claude-code
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.270 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Commit: 97ecbf7abeb4. The embedded JavaScript adds the native candidate solely on stat():
let l = g(P(), ".local", "bin", "claude");
try { await e.stat(l), n.push({ type: "native", path: l }) } catch {}
This branch never checks the symlink target or package ownership. The npm-global candidate followsnpm -g config get prefix; the function neither adds the running executable nor deduplicates targets.
Related: #69833, #56697, #45780. This adds distinct-target and running-install-omission reproductions; it may share their underlying detection problem. Updater behavior was not tested.