Skip to content

Stop/Session hooks fail on Windows when CWD is on a different drive than %USERPROFILE% #285

Open

Description

@gowerlin

Summary

On Windows with Claude Code running in Git Bash / MSYS2, all three plugin hooks (SessionStart, SessionEnd, Stop) fail with MODULE_NOT_FOUND whenever the current working directory is on a different drive than %USERPROFILE%.

Observed error (project on D:\, plugin cache on C:\):

Stop hook error: Failed with non-blocking status code: node:internal/modules/cjs/loader:1386
Error: Cannot find module 'D:\c\Users\Gower\.claude\plugins\cache\openai-codex\codex\1.0.4\scripts\stop-review-gate-hook.mjs'
  code: 'MODULE_NOT_FOUND'

Note the bogus D:\c\ prefix.

Root Cause

hooks/hooks.json passes ${CLAUDE_PLUGIN_ROOT} directly to node:

"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/stop-review-gate-hook.mjs\""

In Git Bash / MSYS2, Claude Code injects CLAUDE_PLUGIN_ROOT in POSIX form (e.g. /c/Users/Gower/.claude/plugins/...). Native node.exe does not understand /c/... — it interprets it as a drive-relative path under the current drive, prepending D: (the project drive) to produce D:\c\Users\..., which does not exist.

This affects all three hooks in 1.0.4/hooks/hooks.json: SessionStart, SessionEnd, Stop.

Repro

  1. Windows 11 + Claude Code in Git Bash / MSYS2.
  2. Install openai/codex-plugin-cc (cached under C:\Users\<user>\.claude\plugins\cache\...).
  3. Open Claude Code in a project located on a different drive (e.g. D:\some\project).
  4. Run anything that triggers the Stop hook (e.g. session ending).
  5. Observe Cannot find module 'D:\c\Users\...' error.

Suggested Fix

Wrap the env var with cygpath -w and fall back to the original value when cygpath is unavailable (Linux/macOS). Apply to all three hook commands:

"command": "node \"$(cygpath -w \"${CLAUDE_PLUGIN_ROOT}\" 2>/dev/null || echo \"${CLAUDE_PLUGIN_ROOT}\")/scripts/stop-review-gate-hook.mjs\""

Alternative: normalize CLAUDE_PLUGIN_ROOT inside the .mjs scripts via path.win32 / url.fileURLToPath so the JSON command stays simple.

Local Workaround

Patched hooks.json in the cache copy with the cygpath wrapper above. After the patch, sessions end cleanly with no MODULE_NOT_FOUND. (The patch is lost on plugin update, hence this report.)

Environment

  • OS: Windows 11 Pro for Workstations (10.0.26200)
  • Shell: Git Bash / MSYS2 (via Claude Code)
  • Node.js: v22.22.2
  • Plugin: openai-codex (codex 1.0.4)
  • Project drive ≠ %USERPROFILE% drive

Activity

  1. CBEPX commented on Sep 29, 2026

    @CBEPX

    I could not reproduce this cross-drive case. Could you retest on the fork v1.4.1 (https://github.com/CBEPX/codex-plugin-cc/releases/tag/v1.4.1) with a working directory on a different drive than %USERPROFILE%? Install: /plugin marketplace add CBEPX/codex-plugin-cc, then /plugin install codex@cbepx. Please report your OS, codex --version, the /codex:status --json output, and the hook error text if it still fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions