Skip to content

PostToolUse hook fails on Windows: ${CLAUDE_PLUGIN_ROOT} path exceeds MAX_PATH #20

Description

@bs966933-tech

Bug

The PostToolUse: Write|Edit|MultiEdit hook in hooks/hooks.json fires on every file edit in Claude Code and fails:

C:\Users\<user>\AppData\Local\Python\pythoncore-3.14-64\python.exe: can't open file
'C:\Users\<user>\AppData\Roaming\Claude\local-agent-mode-sessions\<session-uuid>\<sub-uuid>\rpm\plugin_<ULID>\scripts\check-sql-files.py':
[Errno 2] No such file or directory

The script exists at that path (confirmed via dir/ls), but Windows-native python.exe cannot open it. Every Write/Edit/MultiEdit surfaces a blocking error in Claude Code, breaking the editing flow.

Environment

  • Windows 11
  • Claude Code desktop
  • Plugin: cockroachdb@claude-plugins-official v0.1.9
  • Python: 3.14.3 (Windows native, pythoncore-3.14-64)

Root cause

Claude Code resolves ${CLAUDE_PLUGIN_ROOT} to a per-session sandbox path that nests two UUIDs and a ULID:

C:\Users\<user>\AppData\Roaming\Claude\local-agent-mode-sessions\<UUID>\<UUID>\rpm\plugin_<ULID>\

That prefix is ~170 chars. Plus scripts\check-sql-files.py it's ~250 chars — right against Windows' MAX_PATH (260). Windows long-paths support requires HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled = 1, which is off by default.

So Python's open() fails with Errno 2 even though ls (Cygwin layer) shows the file.

Impact

Affects every Windows user without LongPathsEnabled. The cockroachdb plugin's SQL anti-pattern lint silently breaks the entire Edit flow rather than just failing the check. The PreToolUse hook calling validate-sql.py has the same fragility, just fires less often.

Suggested fixes (any one of these resolves it)

  1. Wrap the hook so script-not-found exits 0, never blocks. A lint hook should never break editing.
  2. Inline the check: for scripts this small, embed the regex check directly in the hooks.json command so no path resolution is needed.
  3. Use python not python3 on Windows: the python3 shim under AppData\Local\Microsoft\WindowsApps adds an indirection layer.
  4. Document the Windows long-path requirement in README.

Local workaround

Remove the PostToolUse block from hooks/hooks.json to stop the noise. Loses the lint feature but unblocks editing.


Reported via Claude Code session, plugin install path:
C:\Users\<user>\.claude\plugins\cache\claude-plugins-official\cockroachdb\0.1.9

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions