[Bug] Auto-Update Mechanism Fails: Broken Symlinks and Corrupted Binary

Resolved 💬 3 comments Opened Oct 8, 2025 by IrumiDesu7 Closed Oct 11, 2025

Bug Description

Root Cause Analysis

The auto-update mechanism has multiple critical failures:

Issue 1: Broken symlink reference

  • Wrapper script at ~/.claude/local/claude hardcodes path to node_modules/.bin/claude
  • Auto-update creates versioned binary .claude-sffaYKUf instead
  • Wrapper script is NOT updated to point to new binary name
  • Result: "No such file or directory" error

Issue 2: Corrupted binary

  • The actual binary cli.js is truncated/incomplete
  • File ends mid-statement at line 1005: modelPreferences:x.optional(f
  • Results in: SyntaxError: missing ) after argument list
  • This suggests download/extraction was interrupted but update proceeded anyway

Expected Behavior

Auto-updates should be atomic:

  • Either complete successfully OR rollback to previous version
  • Never leave the installation in a broken state
  • Update all references (wrapper scripts AND symlinks) together

Actual Behavior

Auto-update is not atomic and leaves installation broken:

  • Partially downloads/corrupts new binary
  • Creates new versioned symlink name
  • Fails to update wrapper script
  • No validation of binary integrity
  • No rollback mechanism

How to Reproduce

Unable to reliably reproduce, but occurs during auto-update process.

Workaround

Complete reinstallation required:

rm -rf ~/.claude/local
npm install -g @anthropic-ai/claude-code  # or use install script

**Environment Info**
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.0.10
- Feedback ID: 59e2549a-cb0f-4f5c-9e30-afaef2cdaa6b

**Errors**
```json
[{"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":"2025-10-08T00:25:56.362Z"}]

View original on GitHub ↗

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