[BUG] Recurring auto-update failures with ENOTEMPTY error

Resolved 💬 7 comments Opened Oct 3, 2025 by MorningLightMountain713 Closed Jan 16, 2026

Preflight Checklist

  • [x] I have searched existing issues 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?

---
Problem

Claude Code's auto-update mechanism repeatedly fails with npm ENOTEMPTY errors,
requiring manual intervention to fix. This has occurred 6+ times for at least
one user.

Error Message

npm error code ENOTEMPTY
npm error syscall rename
npm error path <node_modules>/@anthropic-ai/claude-code
npm error dest <node_modules>/@anthropic-ai/.claude-code-<random>
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '...' -> '...'

Current Workaround

Manual removal and reinstall required:
rm -rf <node_modules>/@anthropic-ai/claude-code
npm i -g @anthropic-ai/claude-code

Root Cause

npm cannot update global packages while they're running. The auto-update
attempts to replace the running package, fails, and leaves the installation in a
broken state.

Suggested Fixes

  1. Defer updates - Don't auto-update while Claude Code is running; schedule for

next launch

  1. Better error recovery - Auto-detect and clean up failed update state before

retrying

  1. Alternative update mechanism - Use a dedicated updater instead of npm's

global package replacement

  1. Graceful degradation - If update fails, continue working without showing

persistent error messages

Impact

This creates a poor user experience as users see recurring "Auto-update failed"
messages and must manually fix the installation repeatedly.

What Should Happen?

As above

Error Messages/Logs

As above

Steps to Reproduce

Leave claude open long enough

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

It's the version before latest... obviously I couldn't be on latest otherwise I wouldn't be updating

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

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