[BUG] Windows: Failed to canonicalize script path error with relative paths in hooks
GitHub Issue - Do zgłoszenia na anthropics/claude-code
Link: https://github.com/anthropics/claude-code/issues/new
Title
[BUG] Windows: 'Failed to canonicalize script path' error with relative paths in hooks
Body
Description
When using hooks in .claude/settings.json on Windows with relative paths, Claude Code intermittently shows a Windows error dialog:
- Title: "Błąd" (Polish for "Error")
- Message: "Failed to canonicalize script path"
Environment
- OS: Windows 11 (10.0.26200.7171)
- Claude Code: Latest version
- Shell: PowerShell / CMD
Steps to Reproduce
- Create
.claude/settings.jsonwith hooks using relative paths:
{
"hooks": {
"SubagentStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "type .claude\\context\\project-brief.txt 2>nul || echo fallback"
}
]
}
],
"SubagentStop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "echo %date% %time% >> .claude\\logs\\agents.log"
}
]
}
]
}
}
- Run Claude Code and trigger subagents (e.g., use Task tool)
- Error dialog appears intermittently
Expected Behavior
Hooks with relative paths should work correctly, resolving paths relative to the project root.
Actual Behavior
Windows dialog appears with "Failed to canonicalize script path" error. The error is intermittent and doesn't always occur.
Workaround
Using absolute paths in hooks resolves the issue:
"command": "type E:\\Path\\To\\Project\\.claude\\context\\project-brief.txt 2>nul || echo fallback"
Additional Context
- Similar path canonicalization issues have been reported in other projects on Windows (e.g., kohya_ss #3434)
- The issue may be related to mixed path separators (
\vs/) in Windows path handling - Related issues: #4079, #3594
Labels: bug, windows
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
It's still occurring, and in macos.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.