anthropics / anthropics/claude-code
[BUG] doctor misclassifies an npm installation at ~/.local/bin/claude as native
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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
```shell
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.
1. 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
```
2. 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
```
3. 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
```
4. 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
```
5. 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.
6. 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()`:
```js
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 follows
`npm -g config get prefix`; the function neither adds the running executable nor deduplicates targets.
Related: [#69833](https://github.com/anthropics/claude-code/issues/69833), [#56697](https://github.com/anthropics/claude-code/issues/56697), [#45780](https://github.com/anthropics/claude-code/issues/45780). This adds distinct-target and running-install-omission reproductions; it may share their underlying detection problem. Updater behavior was not tested.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.