Hooks fail when working directory path contains spaces (macOS)

Resolved 💬 3 comments Opened Mar 26, 2026 by Ron-umbra Closed Apr 29, 2026

Bug Description

All hooks (command type) fail with a non-blocking error when the working directory path contains spaces:

Stop hook error: Failed with non-blocking status code: /bin/sh: /Volumes/PRO-G40/Dropbox/Tech: No such file or directory

This affects every hook type — Stop, PreToolUse, PostToolUse, UserPromptSubmit, SessionStart — because the error occurs before the hook script is invoked. The shell word-splits the CWD path and attempts to execute the first segment as a binary.

Reproduction Steps

  1. Open Claude Code in a directory with spaces in the path, e.g.:

``
/Volumes/MyDrive/Dropbox/Tech Tap Solutions/AI/Claude/MyProject
``

  1. Have any command-type hook configured (settings.json or plugin)
  2. Trigger the hook (e.g., Stop event, or any tool use for PreToolUse hooks)
  3. Observe: Failed with non-blocking status code: /bin/sh: /Volumes/MyDrive/Dropbox/Tech: No such file or directory

Root Cause

The error format /bin/sh: /path/with/spaces: No such file or directory (exit 127) indicates the unquoted CWD path is being passed as a command to /bin/sh -c, causing word splitting. Confirmed by reproducing:

$ /bin/sh -c '/Volumes/PRO-G40/Dropbox/Tech Tap Solutions/test'
/bin/sh: /Volumes/PRO-G40/Dropbox/Tech: No such file or directory

The hook scripts themselves are not the issue — they all exit 0 when invoked manually from the same directory with the same stdin input. The failure is in Claude Code's hook process spawning.

Environment

  • Claude Code version: 2.1.84
  • OS: macOS 15.5 (Darwin 25.4.0)
  • Shell: zsh
  • Working directory: /Volumes/PRO-G40/Dropbox/Tech Tap Solutions/AI/Claude/HomeScope - Real Estate Analytics

Impact

  • All 18 hook commands (settings.json + plugins) fail silently on every event
  • DevFlow tracking, Apex doom-loop detection, write-guard security scanning, auto-formatting — none execute
  • Error toast appears on every Stop (7 hooks), every tool use (4+ hooks), and every prompt submit

Related Issues

  • #16152 — Windows: Hooks fail when user path contains spaces (unquoted ${CLAUDE_PLUGIN_ROOT})
  • #15481 — security-guidance plugin hook fails on Windows paths with spaces

Those are Windows-specific and about CLAUDE_PLUGIN_ROOT path quoting. This issue is macOS-specific and about the CWD path not being properly quoted when hooks are spawned.

View original on GitHub ↗

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