Codex incorrectly uses Git Bash as primary shell on Windows, chaining Git Bash → PowerShell → python, causing python.exe 0xC0000142
What version of the VS Code extension are you using?
v.0.4.46
What subscription do you have?
Plus
Which IDE are you using?
VS Code
What platform is your computer?
Windows 11 25H2 ARM64
What issue are you seeing?
Codex takes an unnecessarily long and fragile execution path when trying to run Python on Windows. Even though Python is installed system-wide and works normally, Codex chooses a chain like:
Git Bash → PowerShell → Python → (sometimes WindowsApps/python.exe)
…instead of simply using Windows PowerShell directly.
This results in:
- failed retries,
- “Fixing quoting style” auto-mutations,
- Codex introspection texts like
I’m working through complex quoting and encoding issues to insert a UTF-8 text block containing backticks and Unicode arrows into a file via a Python script called from PowerShell. I'm exploring using single-quoted here-strings in PowerShell to avoid backtick escapes, switching Unicode arrows to ASCII "->" for compatibility, and writing the script to a file before execution to simplify the command. This careful juggling aims to avoid byte boundary errors and quoting headaches while preserving the insert’s formatting.
<img width="817" height="1379" alt="Image" src="https://github.com/user-attachments/assets/23e5dfca-f018-4930-8bff-1ad401293387" />
- unnecessary escaping gymnastics and here-string workarounds,
- and, critically, a Windows error popup:
<img width="913" height="343" alt="Image" src="https://github.com/user-attachments/assets/1d76e101-641f-4f9a-b155-ef78bcbc33e7" />
python.exe - Application Error The application was unable to start correctly (0xc0000142). Click OK to close the application.
This popup appears almost every time Python is involved in a Codex-triggered operation.
It does not happen when running the same Python commands manually in PowerShell — only when Codex triggers them through the Git Bash → pwsh → python pipeline.
The behavior is impressive in how much effort it puts into multi-shell quoting, but also inefficient and fragile. No instruction in AGENTS.md explains why Codex must run through Git Bash first when a native PowerShell environment is fully available and stable.
Attached screenshots show the error dialogs and the shell output Codex produces.
What steps can reproduce the bug?
- Install Python on Windows (system-wide).
- (Optional) Install Git for Windows — not confirmed, but may influence shell selection.
- In VSCode with Codex enabled, activate Sandbox mode.
- Open a chat with Codex and ask it to run a Python script or apply an auto-fix that generates Python code.
What is the expected behavior?
- PowerShell must be the primary shell on Windows when WSL is not enabled.
- Git Bash should only be used if the user has explicitly requested it.
- Python execution should follow the native Windows execution path, without invoking Git Bash unless explicitly requested.
- No python.exe 0xC0000142 errors thrown.
Additional information
Python 3.14.0
PowerShell 7.5.4
git 2.52.0.windows.1
This happens even when my default VSCode terminal profile is set to PowerShell — Codex still launches the command through Git Bash.
23 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
@nos1609, which model are you using? With the recently-introduced
gpt-5.1-codex-maxmodel, you should see better behavior on Windows than with previous models.Just checked, it is happening right on max model for me.
Codex tries explaining it itself
!Image
Yes, I also encountered this problem. I asked the official to help check the problem. It has been bothering me for two days.
Same problem here for two days.
Same problem here Codex 0.63.0
Same problem
same problem, codex answers some weird/mistake explainations about it like "it's your enviroment issue, try these commands in cursor terminal", which all runs OK (all PATH's are correct), but any command codex's trying to run with "@" in it causes this error window from python
Same problem in CodeX VSCode plugin v0.4.47 with gpt-5.1-codex-max
Yah I'm also having this stupid issue from long time, it's waste of purchase buying Codex instead of Claude
Same problem in CodeX cli newest version (2025-12-07) with gpt-5.1-codex-max on Win11.
Hey @nos1609, can you share the thread-id of a session where you're seeing this issue? You can get the thread-id via the
/feedbackcommand in the extension. Thanks@sayan-oai Yep, found it!
Feedback ID
019abcba-3d4f-7341-bda3-a9ee1c9948fbsame problem with gpt-5.1-codex-max, not just for python.exe often but PowerShell too occasionally
+1 gpt-5.2 with python and powershell on windows. Quite annoying
@nos1609 Thanks for sharing.
Digging through the logs for that session, I only see one
pythoninvocation in any form (python scripts/<script_name>.py), and it completes successfully withExit code: 0.I don't see any failing
pythoninvocations, and I also don't see anything that appears to bebash -> powershellchaining done by the model; I only see youruser_messageinputs where these issues are discussed, not actual instances of the bug happening.Could you share the thread-id of a session where the model actually runs those commands, causing failures? Thanks.
@sayan-oai, I'm not sure if this is exactly the same issue, but I semi-frequently get the python error dialogues.
I am on Windows using PowerShell, and also have Git Bash installed.
I managed to get it to happen and here is the thread-id:
019b29cd-befc-7fa2-8da0-96fc569fe92a
I checked the file it said it was attaching, and found
Exit code: 1appeared several times.Around the time of the error dialogues, the transcript showed commands that failed with ParserError, which I think might be related to the dialogues appearing.
For example: "No characters are allowed after a here-string header but before the end of the line." or "Missing file specification after redirection operator.".
I also noticed two instances of
Exit code: 124which matches the number of times the python error dialogue appeared in that session. Both of which have much higherWall Timevalues than the rest.Hello.
I am getting the same error, but with Git. Apparently, I am using GPT 5.1 codex max, with reasoning level set to high. Whenever it trys to run a command it always throws an error:
git.exe - Application Error dialog The application was unable to start correctly (0xc0000142). Click OK to close the application.
codex-cli 0.73.0
This has never happened before. I thought it's my Git problem. I've reinstalled Git several times, updated, Git runs fine from the terminal, but with Codex? It always throws this error.
We've made a bunch of improvements in Windows since this bug was originally filed. I'm going to close this issue. If you're seeing similar problems with the latest version of Codex, please use the
/feedbackcommand to upload your logs and session details and file a new bug report.Yes, I've felt that the tool access issues were not happening since couple of days,
I'm glad our issue reporting was useful for OpenAI itself as whole, it was very fundamental issue which will make users decide to never use Codex again.
> We've made a bunch of improvements in Windows since this bug was originally filed. I'm going to close this issue. If you're seeing similar problems with the latest version of Codex, please use the
/feedbackcommand to upload your logs and session details and file a new bug report.@etraut-openai haven't seen any issues today with PowerShell use of python. Glad to see such progress there. Thank you for finding the root of the issue.