claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Bug] Auto-update fails with ENOTEMPTY on macOS 15+ due to stale temp directories and extended attributes

Open ajbmachon opened this issue 1 month ago • 1 comments

Bug Description Auto-update fails repeatedly with ENOTEMPTY error on macOS 15+ with nvm. The root cause is a combination of three factors: (1) macOS adds com.apple.provenance extended attributes to all downloaded files which interfere with npm's rename operations, (2) npm uses deterministic temp directory names so when a rename fails the leftover temp directory blocks all future attempts, and (3) auto-update runs while Claude is active causing file locks. This creates a permanent failure loop where each auto-update attempt fails because the previous attempt left a .claude-code-XXXXX temp directory behind. The provenance attributes are re-added immediately after every fresh install, so even manual cleanup only works until the next auto-update. Suggested fixes: clean up stale temp directories before update, use unique temp directory names with timestamps, or strip extended attributes before rename. Affects macOS 26.1 Tahoe and 15.x Sequoia with nvm. Related issues 7373, 6864, 12026.

Environment Info

  • Platform: darwin
  • Terminal: zed
  • Version: 2.0.53
  • Feedback ID: 4173155c-df9b-4b22-9d3c-5d61fa4ac89b

Errors

[{"error":"K51: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym'\nnpm error A complete log of this run can be found in: /Users/andremachon/.npm/_logs/2025-11-27T07_33_08_206Z-debug-0.log\n    at FRA (file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2709:457)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2711:9753","timestamp":"2025-11-27T07:33:08.788Z"},{"error":"Error: Request was aborted.\n    at XT.makeRequest (file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1312:3939)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-11-27T07:34:01.592Z"},{"error":"K51: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym'\nnpm error A complete log of this run can be found in: /Users/andremachon/.npm/_logs/2025-11-27T07_34_21_659Z-debug-0.log\n    at FRA (file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2709:457)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2711:9753","timestamp":"2025-11-27T07:34:22.017Z"},{"error":"K51: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym'\nnpm error A complete log of this run can be found in: /Users/andremachon/.npm/_logs/2025-11-27T07_34_25_339Z-debug-0.log\n    at FRA (file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2709:457)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2711:9753","timestamp":"2025-11-27T07:34:25.626Z"},{"error":"K51: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/andremachon/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/.claude-code-3Jc47Hym\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/andremachon/.nvm/versions/node/v22.14.0/lib/no

Note: Error logs were truncated.

ajbmachon avatar Nov 27 '25 07:11 ajbmachon