Skip to content

Codex Windows hooks use POSIX single-quoted script paths, causing Node MODULE_NOT_FOUND #3392

@SaberMage

Description

@SaberMage

GSD Version

Installed hook scripts report gsd-hook-version: 1.41.2.

Runtime

Codex CLI

Operating System

Windows

Shell

PowerShell / Windows shell invocation from Codex hooks

What happened?

GSD-managed Codex hooks on Windows can be emitted with POSIX-style single quotes around the hook script path, for example:

command = "\"C:/nvm4w/nodejs/node.exe\" 'C:\\Users\\REDACTED\\.codex\\hooks\\gsd-prompt-guard.js'"

When Codex/Windows executes this command, the single quotes are passed as literal path characters. Node then resolves the hook argument relative to the current working directory and fails with MODULE_NOT_FOUND.

Observed failure shape:

Error: Cannot find module 'C:\Users\REDACTED\Documents\projects\rebno\'C:\Users\REDACTED\.codex\hooks\gsd-prompt-guard.js''

This surfaced in Codex as repeated hook warnings:

PreToolUse hook (failed)
error: hook exited with code 1

PostToolUse hook (failed)
error: hook exited with code 1

The affected local commands included GSD Node hooks such as:

  • gsd-prompt-guard.js
  • gsd-read-guard.js
  • gsd-workflow-guard.js
  • gsd-context-monitor.js

What did you expect?

For Windows Codex installs, GSD should emit hook commands using Windows-compatible quoting. For example:

command = "\"C:/nvm4w/nodejs/node.exe\" \"C:/Users/REDACTED/.codex/hooks/gsd-prompt-guard.js\""

or otherwise use a command builder that avoids POSIX single-quote assumptions on Windows.

Steps to reproduce

  1. On Windows, have a GSD-managed Codex hook command with a single-quoted script path:

    "C:/nvm4w/nodejs/node.exe" 'C:\Users\REDACTED\.codex\hooks\gsd-prompt-guard.js'
    
  2. Execute it through the Windows command shell from a project directory.

  3. Node treats the single quotes as literal path characters and fails to load the hook module.

Control check: replacing the script argument with a double-quoted forward-slash path exits successfully:

"C:/nvm4w/nodejs/node.exe" "C:/Users/REDACTED/.codex/hooks/gsd-prompt-guard.js"

Impact

Moderate. The hooks are installed and loaded, but several managed PreToolUse/PostToolUse hooks fail every time they run, adding noisy Codex warnings and disabling the intended guard/context behavior.

Workaround

Manually edit ~/.codex/config.toml or the migrated hook command source and replace single-quoted Windows paths with double-quoted forward-slash paths.

Related

Adjacent to #3362, but this is the Codex-specific Node hook path quoting failure. #3362 discusses PowerShell hook parsing in Gemini and does not cover Node receiving a literal single-quoted Windows path and throwing MODULE_NOT_FOUND.

Privacy Checklist

  • I have reviewed pasted output for PII and redacted local usernames/paths where appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: hooksSession hooks, startup/stopbugSomething isn't workingconfirmed-bugVerified reproducible bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions