Stop hooks fail with ENOENT for /bin/sh on macOS (posix_spawn)

Resolved 💬 5 comments Opened Mar 21, 2026 by thomasandresen Closed Jun 6, 2026

Description

All three Stop hooks fail with ENOENT: no such file or directory, posix_spawn '/bin/sh' on macOS (Apple Silicon, Darwin 25.3.0). The error appears every time Claude stops responding, including on /clear.

Steps to reproduce

  1. Configure Stop hooks in .claude/settings.json:
"Stop": [
  {
    "hooks": [
      { "type": "command", "command": "cd \"$(git rev-parse --show-toplevel)\" && bash .claude/hooks/verify-task-quality.sh" },
      { "type": "command", "command": "cd \"$(git rev-parse --show-toplevel)\" && bash .claude/hooks/context-hygiene-guard.sh" },
      { "type": "command", "command": "cd \"$(git rev-parse --show-toplevel)\" && bash .claude/hooks/auto-ship-guard.sh" }
    ]
  }
]
  1. Run Claude Code and issue any command, or use /clear
  2. Observe the stop hooks all fail

Observed behavior

Ran 3 stop hooks (ctrl+o to expand)
  ⎿  Stop hook error: Failed with non-blocking status code: Error occurred while executing hook command: ENOENT: no such file or directory, posix_spawn '/bin/sh'
  ⎿  Stop hook error: Failed with non-blocking status code: Error occurred while executing hook command: ENOENT: no such file or directory, posix_spawn '/bin/sh'
  ⎿  Stop hook error: Failed with non-blocking status code: Error occurred while executing hook command: ENOENT: no such file or directory, posix_spawn '/bin/sh'

Expected behavior

Stop hooks should execute successfully (or fail silently if non-blocking). /bin/sh exists and is executable:

$ ls -la /bin/sh
-rwxr-xr-x  1 root  wheel  101232 Feb  5 06:13 /bin/sh

Environment

  • macOS (Apple Silicon), Darwin 25.3.0
  • Claude Code (latest)
  • Shell: zsh
  • /bin/sh exists and is accessible
  • The same hooks work fine when triggered as PreToolUse/PostToolUse hooks — only Stop hooks exhibit this behavior

Notes

  • The error comes from Node.js child_process.spawn / posix_spawn — it cannot find /bin/sh in the Stop hook execution context even though it exists on disk
  • This may be a transient issue related to macOS sleep/wake cycles or terminal context, but it reproduces consistently for this user
  • There is currently no way to configure which shell hooks use or to suppress non-blocking hook errors from the UI

View original on GitHub ↗

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