[Bug] SessionEnd/Stop hooks fail to execute on shutdown with posix_spawn ENOENT error

Open 💬 0 comments Opened Jul 11, 2026 by davidwoodward

Bug Description
Title: SessionEnd/Stop hooks fail with posix_spawn '/bin/sh' ENOENT on 2.1.206 — hooks silently never run (regression) Since updating to 2.1.206 (macOS), SessionEnd and Stop hooks fail to execute. Claude Code logs: SessionEnd hook [~/.local/bin/brainer-hook session-end] failed: Error occurred while executing hook command: ENOENT: no such file or directory, posix_spawn '/bin/sh' SessionEnd hook [node ".../session-end-cleanup.mjs"] failed: ... posix_spawn '/bin/sh' Key facts: - It hits every SessionEnd hook — both a shell-command hook and an unrelated node hook — so it's not one hook's problem; it's Claude Code's hook execution during shutdown. - /bin/sh exists and runs fine from every other context (bash, and a python3 subprocess.run(['/bin/sh','-c',...]) both succeed). The /bin/sh ENOENT message is misleading — the shell isn't actually missing. - Clear regression tied to the 2.1.206 update. I have per-session records showing SessionEnd hooks fired normally before the update (33 in one day) and dropped to ~0 the day 2.1.206 was installed. No config changed — same settings.json hook registration, verified valid, and the launcher runs correctly when invoked manually. - Appears to match existing reports #21162, #27674, #20211, #25853 (root cause looks like Node process-teardown timing during shutdown). Impact: Any tool relying on SessionEnd/Stop hooks silently stops working — no error surfaced to the user, hooks just never run. In my case an end-of-session summarizer stopped processing sessions in real time. Possibly related: macOS now shows permission prompts attributed to the bare version string "2.1.206" ("2.1.206 wants to control Terminal" / "2.1.206 was prevented from modifying apps on your Mac"), which appear to be side effects of the abnormal shutdown sequence. Showing prompts as a bare version number instead of "Claude Code" is also confusing and alarming from a user's perspective. Environment: macOS, Claude Code 2.1.206, ~/.local/bin/claude → ~/.local/share/claude/versions/2.1.206.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.1.206
  • Feedback ID: fab97fe4-9d7d-4e8e-93db-2e089cc6ba98

Errors

[]

View original on GitHub ↗