claude-code - 💡(How to fix) Fix Auto-updater has a design flaw that causes silent... [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51710Fetched 2026-04-22 07:54:55
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Error Message

[{"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

Root Cause

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.

Code Example

[{"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
RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

The most likely fix is to detect and remove orphan .claude-code-* directories on startup to prevent silent failure accumulation.

Guidance

  • The issue is caused by the auto-updater running npm install -g from inside the running Claude binary, which fails due to file handles held by the running process.
  • To verify the issue, check for orphan .claude-code-* directories in the .npm-global/lib/node_modules/@anthropic-ai/ directory.
  • A potential workaround is to manually delete these orphan directories to allow updates to proceed.
  • Implementing the suggested fix (Option 1) would involve adding ~5 lines of code to detect and remove these directories on startup.

Example

No code example is provided as the issue does not require a specific code snippet to understand the solution.

Notes

The provided error logs suggest that the issue is related to the auto-updater failing due to file system constraints, but the exact implementation details of the fix may vary depending on the specific requirements of the Claude application.

Recommendation

Apply workaround: detect and remove orphan .claude-code-* directories on startup. This is the easiest and most straightforward solution to prevent silent failure accumulation, as suggested in the issue description.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Auto-updater has a design flaw that causes silent... [1 comments, 2 participants]