Windows: bundled runtime ships a git without bash.exe and never adds usr\bin to PATH, so shell=bash / shell=sh always degrade to cmd.exe
What version of Codex CLI is running?
codex-cli 0.171.0-alpha.13, bundled with Codex Desktop 26.1117.3838.0 (app\resources\codex.exe). The standalone codex-cli 0.167.0-alpha.4.1 behaves the same way.
What subscription do you have?
N/A — this is shell discovery and runtime packaging, no model or subscription is involved (the resolution code path is provider-independent).
Which model were you using?
N/A (not model-dependent).
What platform is your computer?
Microsoft Windows NT 10.0.26300.0 x64
What terminal emulator and version are you using (if applicable)?
No terminal: reproduced from codex exec (stdout is not a TTY) and from the Codex Desktop app.
Codex doctor report
Trimmed for privacy; the relevant fields:
os Windows 10.0.26300 (Windows 11 Professional) [64-bit]
console input code page 936
sandbox backend elevated
runtime version 0.171.0-alpha.13
What issue are you seeing?
On Windows, Codex ships a POSIX-capable git in its primary runtime, but that runtime cannot actually provide a POSIX shell, so shell: "bash" and shell: "sh" can never resolve from it and fall through to cmd.exe.
The bundled runtime tree (...\OpenAI.CodexPrimaryRuntime.v26-1117-835-0...\dependencies\native\git\, also %USERPROFILE%\.cache\codex-runtimes\codex-primary-runtime\dependencies\native\git\ in older installs) looks like this:
native\git\
├── cmd\ git.exe, git-upload-pack.exe, git-receive-pack.exe, scalar.exe
├── etc\
├── ucrt64\
└── usr\
├── bin\ awk, cat, grep, ls, sed, ... and sh.exe <-- no bash.exe
└── ...
- There is no
bin\directory at all, anddir /s /b ...\native\git\bash.exefinds nothing. ...\native\git\usr\bin\sh.exedoes exist (~2.4 MB).- The tool-process
PATHthat Codex builds adds...\dependencies\native\git\cmd, but never...\dependencies\native\git\usr\bin. So even thesh.exethat is shipped is invisible towhich("sh").
Resolution consequences (codex-rs/shell-command/src/shell_detect.rs):
get_bash_shell()→which("bash"), thenBASH_FALLBACK_PATHS = ["/bin/bash", "/usr/bin/bash"](meaningless on Windows) →None.get_sh_shell()→which("sh"), thenSH_FALLBACK_PATHS = ["/bin/sh"]→ on Windows that is a drive-relative path (<current-drive>:\bin\sh), which does not exist in practice →None.get_shell_by_model_provided_path()then does.unwrap_or_else(ultimate_fallback_shell), andultimate_fallback_shell()iscmd.exeon Windows — silently, withexit_code: 0.
So on a Windows machine without a user-installed Git, Codex has no POSIX shell at all, even though its own runtime ships the MSYS binaries and one is one directory away.
What steps can reproduce the bug?
-
Install Codex Desktop on a Windows machine that does not have Git for Windows installed (or remove
<Git>\binfromPATH), i.e.where bashreturns nothing. -
Inspect the bundled runtime:
dir /s /b "%LOCALAPPDATA%\..\..\.cache\codex-runtimes\codex-primary-runtime\dependencies\native\git\bash.exe" dir /b "C:\Program Files\WindowsApps\OpenAI.CodexPrimaryRuntime.*\dependencies\native\git\usr\bin\sh.exe"→ no
bash.exeanywhere;sh.exepresent. -
In Codex, ask the agent to run
echo BASHOK; uname -swithshell: "bash"(orshell: "sh"). -
Observed command event:
{"type":"item.completed","item":{"id":"item_2","type":"command_execution", "command":"cmd.exe /c 'echo BASHOK; uname -s'", "aggregated_output":"BASHOK; uname -s\r\n","exit_code":0,"status":"completed"}}unamenever ran; the tool result looks successful.
This also explains why a standard Git for Windows install does not help: the installer's default option adds only <Git>\cmd to PATH, while bash.exe lives in <Git>\bin (<Git>\cmd\bash.exe does not exist). The Windows-only C:\Program Files\Git\... fallbacks proposed in #40328 fix that specific layout, but not machines with no user Git, portable installs, or non-standard install roots.
What is the expected behavior?
Any one of these would close the gap:
- Ship a
bash.exein the runtime git (a copy/hardlink ofusr\bin\sh.exeis enough for POSIX semantics —sh.exeis already MSYS bash), and/or add...\dependencies\native\git\usr\binto the toolPATHsowhich("sh")works. - Add Windows fallback discovery based on the
gitCodex itself resolves: ifwhich("git")is<X>\cmd\git.exe, also probe<X>\bin\bash.exeand<X>\usr\bin\bash.exe; and add the standard%ProgramFiles%\Git\...paths. - Regardless of discovery, stop substituting
cmd.exesilently: return a tool error the model can read (e.g. "shellbashis not available; found: powershell, cmd") instead ofcmd.exewithexit_code: 0(#40328).
Additional information
Related: #40328 (explicit Git Bash shell falls back to cmd.exe), #16579 (configurable default session shell). This report is only about the runtime/PATH side — the shipped runtime cannot supply a POSIX shell even to itself, independent of what the user has installed.
Security note: the existing behaviour that a model-provided path only selects the shell type and is never executed directly (#39607) should be preserved by any of the above — discovery would only ever use Codex's own resolved paths.
is this expected that the Windows Bundled runtime ship a github with a bash.exe? sh.exe is more advanced why not just use that? what happen is that cmd.exe was used for you, when clearly sh.exe is a thing i recomend that you also check how sh is defined for example ""Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh)."""
https://linux.die.net/man/1/sh
what ever you tried to do didnt work because the lack of bash? are you trying to just make new git commits?
there is https://cli.github.com/ also
github-cli which works beautifully see https://cli.github.com/manual/
for example you can take your coding agents (for example codex and tell it [please use gh please see the latest pull requests ])
(critism i have on github i think they should allow some ratelimiting of visiting of the github pages because many users dont bother to sign in using github-cli )
JSON Fields
assignees, author, blockedBy, blocking, body, closed, closedAt, closedByPullRequestsReferences, comments, createdAt, id, isPinned, issueType, labels, milestone, number, parent, projectCards, projectItems, reactionGroups, state, stateReason, subIssues, subIssuesSummary, title, updatedAt, url
Examples
$ gh issue list --label "bug" --label "help wanted"
$ gh issue list --author monalisa
$ gh issue list --app dependabot
$ gh issue list --assignee "@me"
$ gh issue list --milestone "The big 1.0"
$ gh issue list --search "error no:assignee sort:created-asc"
$ gh issue list --state all
$ gh issue list --type Bug
you seems like an experimental users you might like NU https://www.nushell.sh/book/thinking_in_nu.html#but-it-s-not-bash which works fine on windows for me (as of evaluation i did on it)
also the codex app - is now available on Linux
if you are thinking of migrating from Windows to Linux - i recommend you use Linux Fedora (highly credited for being better than the issues that plagues Debian ) codex app works beautifully on linux too <3
Thanks — let me close the "why not just use sh.exe" question with concrete data, because it's the right question to ask and the answer is a bit surprising.
Scope note first: this report is not about git commits or gh. git and gh work fine on the affected machine; the bug is only about how exec_command resolves shell on Windows.
1. In Git for Windows, sh.exe is bash.exe
Not "more advanced" — literally the same binary. On a normal Git for Windows 2.55 install the two files are byte-identical:
bash.exe 2449886 bytes SHA256 5490D0DA5E7CF9D92068CC48FCC590F2BCF8564ADD8FF91C3B5FE541EB2D72E3
sh.exe 2449886 bytes SHA256 5490D0DA5E7CF9D92068CC48FCC590F2BCF8564ADD8FF91C3B5FE541EB2D72E3
The copy that ships in the Codex runtime behaves the same way:
> ...\dependencies\native\git\usr\bin\sh.exe -c 'echo "BASH_VERSION=$BASH_VERSION"; echo "0=$0"'
BASH_VERSION=5.3.15(2)-release
0=/usr/bin/sh
So Codex already has an sh shell type, and "switch to sh" does not dodge anything — it hits the same two blockers below.
2. What the bundled runtime actually contains
...\OpenAI.CodexPrimaryRuntime.v26-1117-835-0...\dependencies\native\git\:
cmd\ git.exe, git-receive-pack.exe, git-upload-pack.exe, scalar.exe
usr\bin\ 82 files (57 exes): awk, cat, cp, cut, diff, echo, env, expr, find, grep,
head, ls, mkdir, mktemp, mv, printf, pwd, rm, sed, sh, sort, ssh*, tail,
test, touch, tr, uname, uniq, wc, xargs, ...
- There is no
bash.exeanywhere in the whole package (dir /s /b <pkg>\bash.exe→ File Not Found), and nobin\directory either. tar.exeis absent too — this is a trimmed MSYS, not a full Git Bash.- So "just use
sh.exe" means "use the one MSYS binary that happens to be spelledsh", which is exactly the file that is shipped and exactly the file that Codex cannot reach.
3. Two independent blockers — fixing only one does nothing
| blocker | evidence | |
|---|---|---|
| A | No bash.exe file name exists in the runtime, so which("bash") can never match it |
dir /s /b <pkg>\bash.exe → nothing |
| B | usr\bin is never on the tool PATH, so which("sh") cannot match the file that does exist |
the PATH Codex assembles ends with ...\dependencies\native\git\cmd; there is no ...\native\git\usr\bin entry anywhere |
Consequences:
- Copying
sh.exe→bash.exeinsideusr\binalone does not help (still not onPATH). - Adding
usr\bintoPATHalone does not help either (nothing namedbash, andSH_FALLBACK_PATHS = ["/bin/sh"]is a POSIX path that resolves to<current-drive>:\bin\shon Windows). - Codex's own fallback lists are Unix-only —
BASH_FALLBACK_PATHS = ["/bin/bash", "/usr/bin/bash"]— so no Windows location is ever probed.
4. Even the shipped sh.exe becomes a broken environment without PATH
Run directly, outside Codex, with usr\bin not on PATH:
> ...\native\git\usr\bin\sh.exe -c 'uname -s'
sh.exe: /usr/bin/sh: line 1: uname: command not found
uname.exe is sitting right next to sh.exe, but MSYS does not add its own directory to PATH for -c. So if the runtime's shell were ever wired in, usr\bin would have to be on PATH anyway for the coreutils to work. This is the same missing PATH entry as blocker B.
Meanwhile, on a machine that has Git installed, where sh resolves to ...\Git\bin\sh.exe (user install), never to the runtime copy — which is why bash works for people who installed Git and have <Git>\bin on PATH, and fails silently for everyone else.
5. Two tangents from the previous comment, for completeness
- nushell:
detect_shell_type()only recogniseszsh,bash,sh,powershell,cmd. Any other shell name (nu,elvish, a full path tofish, …) is an unknown type and falls into the samecmd.exefallback, so switching shells would trigger this bug rather than avoid it. - Linux/Fedora: not related to this report; the issue is Windows shell discovery in the bundled runtime.
6. Back to the fix
The three options in the report stand, and none of them requires shipping a full Git Bash:
- Ship/alias
bash.exeand addusr\bintoPATH(both blockers). - Probe paths instead of only
which(): ifwhich("git")=<X>\cmd\git.exe, also try<X>\bin\bash.exeand<X>\usr\bin\bash.exe; plus the standard%ProgramFiles%\Git\...locations. No new binaries. - Return a tool error instead of silently using
cmd.exe(tracked in #40328) — no new binaries, and it makes the remaining cases debuggable instead of "successful".
All of these keep the #39607 property that a model-provided path only selects the shell type and is never executed directly.
Thanks — let me close the "why not just use
sh.exe" question with concrete data, because it's the right question to ask and the answer is a bit surprising.Scope note first: this report is not about git commits or
gh.gitandghwork fine on the affected machine; the bug is only about howexec_commandresolvesshellon Windows.1. In Git for Windows,
sh.exeisbash.exeNot "more advanced" — literally the same binary. On a normal Git for Windows 2.55 install the two files are byte-identical:
bash.exe 2449886 bytes SHA256 5490D0DA5E7CF9D92068CC48FCC590F2BCF8564ADD8FF91C3B5FE541EB2D72E3 sh.exe 2449886 bytes SHA256 5490D0DA5E7CF9D92068CC48FCC590F2BCF8564ADD8FF91C3B5FE541EB2D72E3The copy that ships in the Codex runtime behaves the same way:
> ...\dependencies\native\git\usr\bin\sh.exe -c 'echo "BASH_VERSION=$BASH_VERSION"; echo "0=$0"' BASH_VERSION=5.3.15(2)-release 0=/usr/bin/shSo Codex already has an
shshell type, and "switch tosh" does not dodge anything — it hits the same two blockers below.2. What the bundled runtime actually contains
...\OpenAI.CodexPrimaryRuntime.v26-1117-835-0...\dependencies\native\git\:cmd\ git.exe, git-receive-pack.exe, git-upload-pack.exe, scalar.exe usr\bin\ 82 files (57 exes): awk, cat, cp, cut, diff, echo, env, expr, find, grep, head, ls, mkdir, mktemp, mv, printf, pwd, rm, sed, sh, sort, ssh*, tail, test, touch, tr, uname, uniq, wc, xargs, ...
- There is no
bash.exeanywhere in the whole package (dir /s /b <pkg>\bash.exe→ File Not Found), and nobin\directory either.tar.exeis absent too — this is a trimmed MSYS, not a full Git Bash.- So "just use
sh.exe" means "use the one MSYS binary that happens to be spelledsh", which is exactly the file that is shipped and exactly the file that Codex cannot reach.3. Two independent blockers — fixing only one does nothing
blocker evidence A No
bash.exefile name exists in the runtime, sowhich("bash")can never match itdir /s /b <pkg>\bash.exe→ nothing Busr\binis never on the toolPATH, sowhich("sh")cannot match the file that does exist thePATHCodex assembles ends with...\dependencies\native\git\cmd; there is no...\native\git\usr\binentry anywhere Consequences:
- Copying
sh.exe→bash.exeinsideusr\binalone does not help (still not onPATH).- Adding
usr\bintoPATHalone does not help either (nothing namedbash, andSH_FALLBACK_PATHS = ["/bin/sh"]is a POSIX path that resolves to<current-drive>:\bin\shon Windows).- Codex's own fallback lists are Unix-only —
BASH_FALLBACK_PATHS = ["/bin/bash", "/usr/bin/bash"]— so no Windows location is ever probed.4. Even the shipped
sh.exebecomes a broken environment withoutPATHRun directly, outside Codex, with
usr\binnot onPATH:> ...\native\git\usr\bin\sh.exe -c 'uname -s' sh.exe: /usr/bin/sh: line 1: uname: command not found
uname.exeis sitting right next tosh.exe, but MSYS does not add its own directory toPATHfor-c. So if the runtime's shell were ever wired in,usr\binwould have to be onPATHanyway for the coreutils to work. This is the same missingPATHentry as blocker B.Meanwhile, on a machine that has Git installed,
where shresolves to...\Git\bin\sh.exe(user install), never to the runtime copy — which is whybashworks for people who installed Git and have<Git>\binonPATH, and fails silently for everyone else.5. Two tangents from the previous comment, for completeness
- nushell:
detect_shell_type()only recogniseszsh,bash,sh,powershell,cmd. Any other shell name (nu,elvish, a full path tofish, …) is an unknown type and falls into the samecmd.exefallback, so switching shells would trigger this bug rather than avoid it.- Linux/Fedora: not related to this report; the issue is Windows shell discovery in the bundled runtime.
6. Back to the fix
The three options in the report stand, and none of them requires shipping a full Git Bash:
- Ship/alias
bash.exeand addusr\bintoPATH(both blockers).- Probe paths instead of only
which(): ifwhich("git")=<X>\cmd\git.exe, also try<X>\bin\bash.exeand<X>\usr\bin\bash.exe; plus the standard%ProgramFiles%\Git\...locations. No new binaries.- Return a tool error instead of silently using
cmd.exe(tracked in Windows regression: explicit Git Bashexec_command.shellfalls back tocmd.exe#40328) — no new binaries, and it makes the remaining cases debuggable instead of "successful".All of these keep the #39607 property that a model-provided path only selects the shell type and is never executed directly.
you dont need bash, you got powershell,,,,,
maybe it doesnt uses powershell- which is an incorrect behavior...
PowerShell isn't the problem — shell: "powershell" works and I use it. bash/sh are wanted because Codex is POSIX-first (-lc login shells, rg/sed/awk, heredocs), and some tasks need POSIX semantics that PowerShell doesn't provide.
The bug is the silent substitution: an unresolvable bash runs under cmd.exe and returns exit_code: 0, so the model spends an extra round-trip discovering the command did nothing — 2 model calls, 2× latency and a polluted context for a single step.
Measured on one Windows machine: 104 bash requests in a single session, all executed by cmd.exe; after making bash resolvable, 714/714 ran in bash.exe and cmd.exe usage dropped to 0. That duplicated round-trip per bash step is the actual cost — not the choice of shell.
PowerShell isn't the problem —
shell: "powershell"works and I use it.bash/share wanted because Codex is POSIX-first (-lclogin shells,rg/sed/awk, heredocs), and some tasks need POSIX semantics that PowerShell doesn't provide.The bug is the silent substitution: an unresolvable
bashruns undercmd.exeand returnsexit_code: 0, so the model spends an extra round-trip discovering the command did nothing — 2 model calls, 2× latency and a polluted context for a single step.Measured on one Windows machine: 104
bashrequests in a single session, all executed bycmd.exe; after makingbashresolvable, 714/714 ran inbash.exeandcmd.exeusage dropped to 0. That duplicated round-trip per bash step is the actual cost — not the choice of shell.
why not use linux? Doesnt it have the Codex App?
how did you came to having this issue in the first place
The bug is the silent substitution: an unresolvable bash runs under cmd.exe and returns exit_code: 0, so the model spends an extraround-trip discovering the command did nothing — 2 model calls, 2× latency and a polluted context for a single step.
surely if it discovers it cant do something - it adopt for the rest of the session?
I'm developing a Windows-only app,that's why I don't use Linux.
I encountered this bug the first time I opened codex,maybe due to my computer's chaos environment.
Then I asked another agent to fix it and discovered this bug.
When it fallback to cmd.exe,the model may keep using it but try bash again after several commands.
Thanks for your caring.I hope my response could answer your questions.