codex icon indicating copy to clipboard operation
codex copied to clipboard

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

Open nos1609 opened this issue 1 month ago • 18 comments

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

  • unnecessary escaping gymnastics and here-string workarounds,
  • and, critically, a Windows error popup: Image

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.

nos1609 avatar Nov 25 '25 17:11 nos1609

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

  • #7290
  • #6998
  • #6521

Powered by Codex Action

github-actions[bot] avatar Nov 25 '25 17:11 github-actions[bot]

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

etraut-openai avatar Nov 25 '25 17:11 etraut-openai

gpt-5.1-codex-max Just checked, it is happening right on max model for me.

nos1609 avatar Nov 25 '25 17:11 nos1609

Codex tries explaining it itself

Image

nos1609 avatar Nov 25 '25 22:11 nos1609

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

liguochuan00 avatar Nov 26 '25 02:11 liguochuan00

Same problem here for two days.

ftwftw0 avatar Nov 26 '25 18:11 ftwftw0

Same problem here Codex 0.63.0

bvv-jmedved avatar Nov 27 '25 10:11 bvv-jmedved

Same problem

Alex71711 avatar Nov 27 '25 23:11 Alex71711

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

aegelsky avatar Dec 01 '25 12:12 aegelsky

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

TGSAN avatar Dec 04 '25 10:12 TGSAN

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

kashifo avatar Dec 06 '25 04:12 kashifo

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

MaxMiksa avatar Dec 07 '25 06:12 MaxMiksa

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

sayan-oai avatar Dec 10 '25 18:12 sayan-oai

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

nos1609 avatar Dec 11 '25 11:12 nos1609

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

orazdow avatar Dec 14 '25 04:12 orazdow

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

Sharan123 avatar Dec 15 '25 19:12 Sharan123

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

sayan-oai avatar Dec 15 '25 23:12 sayan-oai

@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 avatar Dec 17 '25 01:12 rmarker

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.

rmarker avatar Dec 17 '25 07:12 rmarker

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.

diamondStar35 avatar Dec 17 '25 21:12 diamondStar35