Auto-updater reinstalls to npm-global after native install, shadowing ~/.local/bin
Description
After switching from npm-global to native installation (claude install), the auto-updater periodically runs npm install -g @anthropic-ai/claude-code, re-creating the binary at ~/.npm-global/bin/claude and shadowing the native install at ~/.local/bin/claude.
This creates a recurring cycle requiring manual cleanup every few hours:
npm -g remove @anthropic-ai/claude-code && claude install
Root Cause
claude installplaces the native binary at~/.local/bin/claude- If
~/.npm-global/binprecedes~/.local/binin PATH (common setup), and the npm-global package exists from a prior installation,which clauderesolves to the npm-global version - The auto-updater detects the running binary's install method:
AutoUpdaterWrapper: Installation type: npm-global - The updater runs
npm install -g @anthropic-ai/claude-code@latest, recreating~/.npm-global/bin/claude - The cycle self-perpetuates — every session from the npm-global binary triggers npm-global updates
Even after npm -g remove, the updater reinstalls within ~1 hour (observed: cleanup at 10:33, reinstalled by 11:47 same day).
Evidence
From debug logs:
2026-01-29T23:39:59.064Z [DEBUG] AutoUpdaterWrapper: Installation type: npm-global
2026-01-30T01:01:31.031Z [DEBUG] AutoUpdaterWrapper: Installation type: npm-global
2026-01-30T05:39:26.941Z [DEBUG] AutoUpdaterWrapper: Installation type: npm-global
Stack traces consistently reference ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js.
Session count from debug logs: 493 sessions from npm-global vs 110 from native ~/.local/share/claude.
Environment
- macOS (Darwin 25.2.0, Apple Silicon)
- Claude Code 2.1.29, native install
- npm prefix:
~/.npm-global(via.npmrc) - Shell: fish
- PATH order:
~/.npm-global/binbefore~/.local/bin @anthropic-ai/claude-codeis NOT in any managed global packages list — not intentionally installed via npm- npm cache contained many cached claude-code versions (2.1.1 through 2.1.20+)
autoUpdatesChannel: "latest"in settings
Expected Behavior
After claude install creates a native installation, the auto-updater should:
- Detect
installation type: nativeregardless of stale npm state - Never run
npm install -gwhen a native install is configured - Ideally clean up any leftover npm-global installation to prevent PATH shadowing
Workaround
# 1. Remove npm-global installation
npm -g remove @anthropic-ai/claude-code
# 2. Clean npm cache (may influence detection)
npm cache clean --force
# 3. Ensure ~/.local/bin precedes ~/.npm-global/bin in PATH
Related Issues
- #21789 — Same class of bug (npm cache misleading updater detection), but for npm-local mode
- #8523 — Incorrect diagnostics for npm-global installation
- #13213 —
autoUpdaterStatus: "disabled"setting is ignored - #17612 — Auto-updater unconditionally writes
installMethod: "global"every 30 min
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗