claude-code - 💡(How to fix) Fix Stale background daemons from prior version cause ENOENT posix_spawn when launching agents after upgrade [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#60634Fetched 2026-05-20 03:53:25
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×5commented ×1

Root Cause

Long-lived background processes from the previous version survive the cask upgrade. The 2.1.128 Caskroom directory has been deleted by Homebrew, but these daemons remain running with the old absolute path in their argv[0]:

PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude daemon run --origin transient --spawned-by {...}
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-pty-host /tmp/cc-daemon-.../spare/....pty.sock 200 50 -- ...
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-spare /tmp/cc-daemon-.../spare/....claim.sock

When a new agent is spawned, the daemon re-execs its own argv[0] (the deleted 2.1.128 path), so posix_spawn returns ENOENT and the "respawning" loop never recovers.

Fix Action

Workaround

pkill -f 'Caskroom/claude-code/2\.1\.128'
# then start a fresh `claude` session — daemon respawns from 2.1.138

Code Example

ENOENT: no such file or directory, posix_spawn '/opt/homebrew/Caskroom/claude-code/2.1.128/claude'; respawning

---

PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude daemon run --origin transient --spawned-by {...}
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-pty-host /tmp/cc-daemon-.../spare/....pty.sock 200 50 -- ...
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-spare /tmp/cc-daemon-.../spare/....claim.sock

---

pkill -f 'Caskroom/claude-code/2\.1\.128'
# then start a fresh `claude` session — daemon respawns from 2.1.138
RAW_BUFFERClick to expand / collapse

What happened

After Homebrew upgraded the claude-code cask from 2.1.128 → 2.1.138, launching any new agent fails with:

ENOENT: no such file or directory, posix_spawn '/opt/homebrew/Caskroom/claude-code/2.1.128/claude'; respawning

Restarting the foreground claude process does NOT fix it.

Root cause

Long-lived background processes from the previous version survive the cask upgrade. The 2.1.128 Caskroom directory has been deleted by Homebrew, but these daemons remain running with the old absolute path in their argv[0]:

PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude daemon run --origin transient --spawned-by {...}
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-pty-host /tmp/cc-daemon-.../spare/....pty.sock 200 50 -- ...
PID  ...  /opt/homebrew/Caskroom/claude-code/2.1.128/claude --bg-spare /tmp/cc-daemon-.../spare/....claim.sock

When a new agent is spawned, the daemon re-execs its own argv[0] (the deleted 2.1.128 path), so posix_spawn returns ENOENT and the "respawning" loop never recovers.

Workaround

pkill -f 'Caskroom/claude-code/2\.1\.128'
# then start a fresh `claude` session — daemon respawns from 2.1.138

Suggested fixes

  • On daemon startup, resolve the binary via /opt/homebrew/bin/claude (or another stable path), not the versioned Caskroom path.
  • Detect a missing argv[0] on respawn and exit cleanly so a new daemon can be started from the current binary, instead of looping.
  • Have the foreground process check the daemon's binary path on connect and kill+respawn the daemon if it points to a deleted version.

Environment

  • macOS (darwin 25.4.0)
  • Installed via Homebrew Cask
  • Affected versions observed: 2.1.128 daemons left over after upgrade to 2.1.138

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