claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Windows: Failed to canonicalize script path error with relative paths in hooks

Open bartoszwarzocha opened this issue 3 months ago • 1 comments

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

  1. Create .claude/settings.json with 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"
          }
        ]
      }
    ]
  }
}
  1. Run Claude Code and trigger subagents (e.g., use Task tool)
  2. 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

bartoszwarzocha avatar Dec 02 '25 10:12 bartoszwarzocha

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.

github-actions[bot] avatar Jan 02 '26 10:01 github-actions[bot]

It's still occurring, and in macos.

shamal avatar Jan 22 '26 20:01 shamal

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Feb 28 '26 10:02 github-actions[bot]

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.

github-actions[bot] avatar Mar 08 '26 14:03 github-actions[bot]