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

Resolved 💬 4 comments Opened Dec 2, 2025 by bartoszwarzocha Closed Feb 28, 2026

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

View original on GitHub ↗

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