[Windows Desktop] Shell child processes get `PATHEXT` truncated to `.CPL`, causing `git`, `cmd`, and other `.exe` commands to stop resolving
What version of the Codex App are you using (From “About Codex” dialog)?
OpenAI Codex Desktop 26.313.5234.0 Windows Store package: OpenAI.Codex_26.313.5234.0_x64__2p2nqsd0c76g0
What subscription do you have?
Chatgpt Plus
What platform is your computer?
Microsoft Windows NT 10.0.22621.0 x64
What issue are you seeing?
Codex Desktop appears to launch some shell child processes with a corrupted PATHEXT.
Inside the broken shell process, the environment contains only:
$env:PATHEXT
.CPL
instead of a normal Windows value such as:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
As a result, bare executable names stop resolving in PowerShell. For example:
git --versionfails withCommandNotFoundExceptioncmd /c ...also fails if invoked without an explicit extension or full path- direct invocation with a full path still works, for example:
& 'C:\Program Files\Git\cmd\git.exe' --version
This breaks Codex shell tool calls on Windows whenever the tool tries to run git, cmd, or other .exe programs by name.
What steps can reproduce the bug?
- Open Codex Desktop on Windows.
- Start a workspace/thread.
- Ask Codex to run:
$env:PATHEXT
- Observe that inside the shell child process, it prints:
.CPL
- Ask Codex to run:
git --version
- Observe that it fails with
CommandNotFoundException. - Run:
& 'C:\Program Files\Git\cmd\git.exe' --version
- Observe that it succeeds.
- In the same broken shell, set:
$env:PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
- Run again:
git --version
- Observe that it immediately starts working.
What is the expected behavior?
Codex should preserve the normal Windows PATHEXT value when spawning shell child processes, so bare .exe commands such as git, cmd, node, etc. resolve the same way they do in a normal PowerShell session.
Additional information
I did some local investigation to narrow this down:
- Machine-level registry
PATHEXTis normal - User-level registry does not override
PATHEXT - My PowerShell profile does not modify
PATHEXT git.exeis installed and present onPATH- Direct full-path execution works
- The parent Codex Desktop processes appear to have a normal
PATHEXT - The corruption appears when
app\resources\codex.exe(app-server --analytics-default-enabled) spawns the PowerShell shell child
My current inference is that the desktop app is rebuilding the child environment incorrectly and truncating PATHEXT to the last segment (.CPL).
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thanks for linking the similar issue, but I do not think my bug is the same one.
In my case, the problem is not that Git is missing, not that
PATHis wrong, and not that PowerShell cannot launch external programs in general. The failure is specifically caused by the shell child process inheriting a corruptedPATHEXTvalue (.CPLonly), which prevents bare.execommand names from resolving.For example, when I try to invoke Git by name inside the broken Codex shell, I get:
However, this does not mean Git is absent.
git.exeis installed, present onPATH, and can be launched successfully by full path. Also, if I restorePATHEXTinside the same broken shell to the normal Windows value,git --versionimmediately starts working again.That behavior strongly suggests this is an environment-construction bug in the spawned shell process, specifically around
PATHEXT, rather than the other reported issue.~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Microsoft.PowerShell_profile.ps1
Confirmed. I had the same root cause: inside the broken shell,
$env:PATHEXTwas only.CPL, so PowerShell stopped resolvinggit->git.exe.Workaround that fixed it for me:
```powershell
[Environment]::SetEnvironmentVariable('PATHEXT','.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC','User')
And to auto-heal future PowerShell sessions, I added this to $PROFILE:
if (-not $env:PATHEXT -or $env:PATHEXT -notmatch '(^|;)\.EXE(;|$)') {
$fixedPathExt = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
$env:PATHEXT = $fixedPathExt
[Environment]::SetEnvironmentVariable('PATHEXT', $fixedPathExt, 'User')
}
```
That restored git --version and Get-Command git for me.