[FEATURE] Failed auto-update leaves stale temp directory, blocks reinstall with opaque npm error

Resolved 💬 3 comments Opened Apr 4, 2026 by tlskr Closed Apr 8, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When the Claude Code auto-updater fails mid-update, it leaves a temporary directory like .claude-code-X3sWxAME in the npm global modules path. Subsequent npm i -g @anthropic-ai/claude-code fails with:

npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/kilroy/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code
npm error dest /Users/kilroy/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/.claude-code-X3sWxAME
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '...' -> '...'

This also means which claude returns nothing — the CLI is completely gone, not just broken.

Environment: macOS, Node v24.12.0 via nvm, npm global install

Issue written up by Claude, Opus 4.6

Proposed Solution

The fix is rm -rf .../.claude-code-* then reinstall, but nothing in the error message suggests that. A user who isn't deeply familiar with npm internals would be stuck.

Suggestions:

  1. The auto-updater should clean up its own temp directories on failure (or on next startup)
  2. If a stale temp dir is detected during install, the installer could remove it automatically or at least print: "A previous update left a temporary directory. Run rm -rf <path> and retry."
  3. Consider a claude doctor or claude repair command that detects and fixes common broken states

Alternative Solutions

_No response_

Priority

Low - Nice to have

Feature Category

Other

Use Case Example

> which claude

failed on my command line because of this

Additional Context

_No response_

View original on GitHub ↗

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