Skip to content

v3.4.1: Codex hooks run on Windows

Latest

Choose a tag to compare

@OthmanAdi OthmanAdi released this 12 Jul 11:01

Codex hooks now run on Windows (closes #201)

Reported by @mahdiit: Codex hooks failed on Windows with hook exited with code 1 on every Bash call.

Cause

The .codex/hooks.json commands were POSIX only (sh, python3, 2>/dev/null, $HOME, a trailing || true). Codex on Windows runs that string through the native command interpreter, not a POSIX shell, so python3 hit the Microsoft Store alias, 2>/dev/null was an invalid path, and the || true success guard itself failed because true is not a Windows command. The chain exited non-zero and Codex reported the hook as failed.

Fix

Each hook now carries a per-hook commandWindows override, the mechanism OpenAI's hooks documentation sanctions. The POSIX command is untouched, so macOS and Linux are byte for byte unchanged. On Windows all seven hooks route through a new launcher, .codex/hooks/pwf-hook.cmd, which selects a real Python (py -3, falling back to python, never the Store python3 alias) and always exits 0. The three shell hooks route through a new front door, .codex/hooks/run_sh.py. codex_hook_adapter resolves the Git for Windows sh.exe by anchoring on git.exe, so the shell scripts run even when Git's usr\bin is off PATH.

On Windows you need Python reachable as py or python, and Git for Windows for the three shell hooks. See docs/codex.md.

Verification

Codex hook suites green (17 tests) plus a new cross-platform guard and a Windows-only end-to-end test. Reproduced and verified fixed on Windows, including the reporter's environment where Git's usr\bin is off PATH, and a no-Git case that degrades to a silent no-op.

Thanks @mahdiit for the report with the exact error and environment.