openai / openai/codex-plugin-cc

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

Open
#285 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
33.3k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in hooks/hooks.json and inspect the SessionStart, SessionEnd, and Stop command definitions that pass CLAUDE_PLUGIN_ROOT to node. Reproduce the failure from Git Bash/MSYS2 with the project and plugin cache on different drives, then verify the chosen path-normalization approach removes MODULE_NOT_FOUND for all three hooks on Windows without breaking Linux or macOS fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, shell
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.