Auto-update fails with ENOTEMPTY when multiple CLI instances are running

Resolved 💬 3 comments Opened Nov 26, 2025 by heikki0 Closed Nov 26, 2025

Description

When running multiple Claude Code CLI instances simultaneously, the auto-update frequently fails with an ENOTEMPTY error, leaving behind stale temporary directories that block all future updates.

Error Message

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

Steps to Reproduce

  1. Open 2-3 Claude Code CLI instances in different terminals
  2. Wait for auto-update to trigger (or trigger manually)
  3. One instance starts the update while others are still using the package
  4. Update fails, leaving .claude-code-XXXX temp directory behind
  5. All subsequent auto-updates fail until manually cleaned up

Current Workaround

rm -rf ~/.nvm/versions/node/*/lib/node_modules/@anthropic-ai/.claude-code-* 
npm update -g @anthropic-ai/claude-code

Suggested Fix

The auto-update mechanism could:

  1. Clean up stale temp directories before attempting update:

``bash
rm -rf ~/.nvm/versions/node/*/lib/node_modules/@anthropic-ai/.claude-code-* 2>/dev/null
``

  1. Use a lock file to prevent concurrent update attempts across instances
  1. Retry with cleanup if the first attempt fails with ENOTEMPTY

Environment

  • Claude Code version: 2.0.51 → 2.0.54
  • Node: v22.13.0 (via nvm)
  • OS: macOS Darwin 24.6.0
  • Installation: npm global install

Impact

Users who regularly run multiple CLI instances (common for multi-project work) experience persistent update failures and see the "Auto-update failed" message constantly until they manually intervene.

View original on GitHub ↗

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