Codex incorrectly uses Git Bash as primary shell on Windows, chaining Git Bash → PowerShell → python, causing python.exe 0xC0000142

Resolved 💬 23 comments Opened Nov 25, 2025 by nos1609 Closed Jan 13, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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?

  1. Install Python on Windows (system-wide).
  2. (Optional) Install Git for Windows — not confirmed, but may influence shell selection.
  3. In VSCode with Codex enabled, activate Sandbox mode.
  4. 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.

View original on GitHub ↗

23 Comments

github-actions[bot] contributor · 7 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #7290
  • #6998
  • #6521

Powered by Codex Action

etraut-openai contributor · 7 months ago

@nos1609, which model are you using? With the recently-introduced gpt-5.1-codex-max model, you should see better behavior on Windows than with previous models.

nos1609 · 7 months ago
gpt-5.1-codex-max

Just checked, it is happening right on max model for me.

nos1609 · 7 months ago

Codex tries explaining it itself

!Image

liguochuan00 · 7 months ago

Yes, I also encountered this problem. I asked the official to help check the problem. It has been bothering me for two days.

ftwftw0 · 7 months ago

Same problem here for two days.

bvv-jmedved · 7 months ago

Same problem here Codex 0.63.0

Alex71711 · 7 months ago

Same problem

aegelsky · 7 months ago

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

TGSAN · 7 months ago

Same problem in CodeX VSCode plugin v0.4.47 with gpt-5.1-codex-max

kashifo · 7 months ago

Yah I'm also having this stupid issue from long time, it's waste of purchase buying Codex instead of Claude

MaxMiksa contributor · 7 months ago

Same problem in CodeX cli newest version (2025-12-07) with gpt-5.1-codex-max on Win11.

sayan-oai contributor · 7 months ago

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 /feedback command in the extension. Thanks

nos1609 · 7 months ago

@sayan-oai Yep, found it!
Feedback ID 019abcba-3d4f-7341-bda3-a9ee1c9948fb

orazdow · 7 months ago

same problem with gpt-5.1-codex-max, not just for python.exe often but PowerShell too occasionally

Sharan123 · 7 months ago

+1 gpt-5.2 with python and powershell on windows. Quite annoying

sayan-oai contributor · 7 months ago

@nos1609 Thanks for sharing.

Digging through the logs for that session, I only see one python invocation in any form (python scripts/<script_name>.py), and it completes successfully with Exit code: 0.

I don't see any failing python invocations, and I also don't see anything that appears to be bash -> powershell chaining done by the model; I only see your user_message inputs 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.

rmarker · 7 months ago

@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: 1 appeared 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.".

rmarker · 7 months ago

I also noticed two instances of Exit code: 124 which matches the number of times the python error dialogue appeared in that session. Both of which have much higher Wall Time values than the rest.

diamondStar35 · 7 months ago

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.

etraut-openai contributor · 6 months ago

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 /feedback command to upload your logs and session details and file a new bug report.

kashifo · 6 months ago

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 /feedback command to upload your logs and session details and file a new bug report.

nos1609 · 6 months ago

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

We've made a bunch of improvements in Windows since this bug was originally filed