Skip to content

Codex Windows Bash hooks assume bash is on PATH and fail with hook exited code 1 #3393

@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?

Some GSD-managed Codex hooks are emitted as shell scripts invoked with bare bash, for example:

"command": "bash 'C:\\Users\\REDACTED\\.codex\\hooks\\gsd-validate-commit.sh'"

and:

"command": "bash 'C:\\Users\\REDACTED\\.codex\\hooks\\gsd-phase-boundary.sh'"

On this Windows machine, Git for Windows is installed, but bash is not on PATH in the PowerShell/Codex environment. Direct reproduction:

The term 'bash' is not recognized as a name of a cmdlet, function, script file, or executable program.

This surfaces in Codex as hook failures, including SessionStart, PreToolUse, and PostToolUse warnings:

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

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

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

The same scripts succeed when invoked with the resolved Git Bash executable:

"C:/Program Files/Git/bin/bash.exe" "C:/Users/REDACTED/.codex/hooks/gsd-session-state.sh"
"C:/Program Files/Git/bin/bash.exe" "C:/Users/REDACTED/.codex/hooks/gsd-validate-commit.sh"
"C:/Program Files/Git/bin/bash.exe" "C:/Users/REDACTED/.codex/hooks/gsd-phase-boundary.sh"

What did you expect?

On Windows, the GSD Codex installer/migrator should not emit bare bash unless it has verified that bash is available in the runtime PATH Codex will use.

Possible fixes:

  • Resolve Git Bash and emit the absolute executable path, for example C:/Program Files/Git/bin/bash.exe.
  • Prefer Node or PowerShell wrappers for these hooks on Windows.
  • If no supported shell is found, skip the Bash-backed hooks with a clear install-time warning instead of installing commands that will fail every time.

Steps to reproduce

  1. Use Windows with Git Bash installed but not exposed as bash on PATH.
  2. Install or migrate GSD Codex hooks that include bash ...gsd-*.sh commands.
  3. Start Codex or trigger a matching tool event.
  4. Hooks fail with exit code 1 because bash cannot be resolved.

Control check: running the same hook scripts with C:/Program Files/Git/bin/bash.exe exits 0.

Impact

Moderate. Managed hooks are installed but fail noisily at runtime. Depending on which hook fires, this can affect session-state injection, commit validation, and phase-boundary reminders.

Workaround

Manually edit ~/.codex/config.toml and replace bare bash commands with the resolved Git Bash executable path, using double-quoted forward-slash paths.

Related

Related to #3362, but this is a Codex runtime/install issue with GSD-managed Bash-backed hooks. #3362 is Gemini-focused and mentions Bash ambiguity as a workaround note; this report captures the concrete Codex failure and successful resolved-path workaround.

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