PreToolUse hook fails with 'hook error (No content)' when path contains spaces

Status Closed — not planned
Maintainer reply None cached
Activity 2 comments · opened Jan 12, 2026 · closed Jan 12, 2026

Description

PreToolUse hooks fail silently with "hook error (No content)" when the hook command path contains spaces (e.g., Google Drive paths).

Environment

  • Claude Code version: v2.1.5
  • OS: macOS (Darwin 24.6.0)
  • Path: /Users/.../GoogleDrive-.../My Drive/Intelligence-Vault/

Configuration

"hooks": {
  "PreToolUse": [
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "command": "/Users/.../My Drive/Intelligence-Vault/.claude/hooks/reject-cd-chaining.py"
        }
      ]
    }
  ]
}

Observed Behaviour

Every Bash tool call fails with:

⏺ Bash(mv wip-prompts/file.md KB-Articles/file.md)
  ⎿  PreToolUse:Bash hook error
  ⎿  (No content)

The hook script itself works correctly when invoked directly from the shell:

echo '{"tool_name":"Bash","tool_input":{"command":"mv test.md out.md"}}' | python3 "/path/with spaces/hook.py"
# Exit code: 0 (correct)

Expected Behaviour

Hook paths containing spaces should be properly escaped/quoted when executed by Claude Code.

Workaround

Remove the hook from settings, or use a path without spaces.

Additional Context

  • Tried both $CLAUDE_PROJECT_DIR variable and absolute path - same result
  • The hook script has a try/except that calls sys.exit(0) on any exception (fail-open), so the error is occurring before the Python script executes
  • Multiple parallel Bash tool calls all fail simultaneously with the same error

View original on GitHub ↗

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