Auto-updater has a design flaw that causes silent...

Resolved 💬 2 comments Opened Apr 21, 2026 by shivsid1 Closed May 26, 2026

Bug Description
Auto-updater has a design flaw that causes silent accumulating failures.

The in-process updater runs npm install -g from inside the running claude binary. npm's atomic rename step fails with ENOTEMPTY because the running process holds open file handles
on claude-code/. The orphan .claude-code-XXXXXX temp dir left behind then blocks every future update attempt until manually deleted.

Result: users who don't restart sessions daily get stuck on old versions silently. I was on 2.0.1 for 3+ days while 2.1.116 was current. The footer warning "try every few months"
suggests the team knows but hasn't fixed it.

Fix options (easiest first):

  1. On startup, detect and rm -rf orphan .claude-code-* dirs — prevents failure accumulation even without fixing the race
  2. Stage updates and apply them on next launch before main process initializes
  3. Fork a detached helper that waits for parent exit, then performs the swap

Option 1 is ~5 lines of code and would solve the silent-failure problem for everyone.

Env: macOS, Node 22, user-owned npm prefix (no perms issues).

Environment Info

  • Platform: darwin
  • Terminal: WarpTerminal
  • Version: 2.0.1
  • Feedback ID: a8ddfcbb-4e83-4d67-9cc6-6353026a8f84

Errors

[{"error":"RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded\n    at Socket.onChildStdout (node:child_process:484:14)\n    at Socket.emit (node:events:518:28)\n    at Socket.emit (node:domain:489:12)\n    at addChunk (node:internal/streams/readable:561:12)\n    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n    at Readable.push (node:internal/streams/readable:392:5)\n    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)","timestamp":"2026-04-21T19:47:40.272Z"},{"error":"fv1: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-vcznjTZZ\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-vcznjTZZ'\nnpm error A complete log of this run can be found in: /Users/shivsid/.npm/_logs/2026-04-21T19_47_43_598Z-debug-0.log\n    at lY1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2204:388)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:3177:8694","timestamp":"2026-04-21T19:47:44.054Z"},{"error":"Error: 404 {\"type\":\"error\",\"error\":{\"type\":\"not_found_error\",\"message\":\"model: claude-3-5-haiku-20241022\"},\"request_id\":\"req_011CaHVcf9zgegua2xxLiUAe\"}\n    at B4.generate (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:21060)\n    at yP.makeStatusError (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:2131)\n    at yP.makeRequest (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:5344)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2026-04-21T19:47:52.338Z"},{"error":"SyntaxError: Unexpected token 'A', \"API Error:\"... is not valid JSON\n    at JSON.parse (<anonymous>)\n    at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:747:9932\n    at Q (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:713:13287)\n    at Hy2 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1046:37066)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2026-04-21T19:47:52.339Z"},{"error":"fv1: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-vcznjTZZ\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-vcznjTZZ'\nnpm error A complete log of this run can be found in: /Users/shivsid/.npm/_logs/2026-04-21T19_47_56_092Z-debug-0.log\n    at lY1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2204:388)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:3177:8694","timestamp":"2026-04-21T19:47:56.242Z"},{"error":"fv1: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/shivsid/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-vcz

Note: Error logs were truncated.

View original on GitHub ↗

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