Auto-updater reinstalls to npm-global after native install, shadowing ~/.local/bin

Resolved 💬 3 comments Opened Feb 1, 2026 by jasonkuhrt Closed Feb 5, 2026

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

  1. claude install places the native binary at ~/.local/bin/claude
  2. If ~/.npm-global/bin precedes ~/.local/bin in PATH (common setup), and the npm-global package exists from a prior installation, which claude resolves to the npm-global version
  3. The auto-updater detects the running binary's install method: AutoUpdaterWrapper: Installation type: npm-global
  4. The updater runs npm install -g @anthropic-ai/claude-code@latest, recreating ~/.npm-global/bin/claude
  5. 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/bin before ~/.local/bin
  • @anthropic-ai/claude-code is 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:

  1. Detect installation type: native regardless of stale npm state
  2. Never run npm install -g when a native install is configured
  3. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗