Windows branch shell.rs frequently and incorrectly handles pwsh, causing command execution failures.
What version of Codex is running?
0.34.0
Which model were you using?
GPT-5-high
What platform is your computer?
Microsoft Windows 10 10.0.19045 x64-based PC
What steps can reproduce the bug?
- Run a command containing quotes or Windows paths on a Windows environment.
- The program incorrectly triggers Unix commands or fails due to escaping issues.
What is the expected behavior?
- Prioritize
pwshin the Windows branch. - If
pwshfails, fallback should be Windows PowerShell, notbash. - Optionally perform a self-check at program startup:
- If Unix tools are required, inform the user clearly to install them instead of silently failing.
- Avoid repeated failures (currently a single execution may fail 5–6 times), as this makes logs noisy and user interaction confusing.
- Use ScriptBlock execution for
pwshcommands to ensure proper escaping.
What do you see instead?
<img width="727" height="439" alt="Image" src="https://github.com/user-attachments/assets/c1b1d7ae-e47a-48c8-b1c4-c861f1a6ae05" />
<img width="973" height="102" alt="Image" src="https://github.com/user-attachments/assets/b9219a4f-7a5f-4874-b21b-59273074c5aa" />
<img width="1085" height="174" alt="Image" src="https://github.com/user-attachments/assets/fb54877a-1ed9-484c-bd68-9c7a3b3915d2" />
<img width="1051" height="266" alt="Image" src="https://github.com/user-attachments/assets/b2de9762-0510-415b-8e21-95e39a15d982" />
Additional information
I previously submitted a PR (#3253
) that attempted to improve this behavior. While the implementation might not have been perfect, in practice it significantly reduced command execution errors and ensured that pwsh was consistently prioritized.
6 Comments
This would be awesome to see improved
Yep, even using Git Bash and explicitly telling it to use bash commands in the AGENTS.md, Codex still gets confused at first
@zheli1119 you wrote:
Do you mean
pwsh.exeshould be the first choice andpowershell.exeshould be the fallback?@bolinfest
Yes, pwsh.exe should be the first choice.
Here’s why:
In an environment like CLI Version: 0.39.0 with PowerShell 7.5.3, command escaping issues have been significantly reduced, though occasional cases still occur.
I’ve also noticed that if the user has Git Bash (X:\Git\bin) included in their system PATH, the agent’s commands almost never fail, making the experience nearly identical to macOS and Linux.
👉 Suggestion: perhaps we could add a detection prompt on Windows.
If no Bash environment is found in the system PATH, recommend the user to install and configure Git Bash.
This would be similar to how Claude Code refuses to run when no Git Bash is detected.
That way, we don’t even need to worry about choosing between pwsh.exe and powershell.exe, completely avoiding unnecessary complexity.
@bolinfest
I found a new bug: when the client machine’s system locale/encoding is non-UTF-8, Codex fails to detect files. It only recognizes files with English (ASCII) names. Even after changing the console OEM code page and/or using pwsh, it still cannot detect files with non-English names.
Codex version: 0.42.0.
This appears to be a serious compatibility issue.
I think this bug is no longer relevant, so I'm going to close. If you're seeing a similar problem in the latest version of Codex, please open a new bug with repro details.