Configuring MSY2 Bash for Codex (on Windows) #3580
Replies: 2 comments 1 reply
-
I have an even stranger problem. My plan is to use Git Bash, which is essentially no different from using MSYS2. Initially, I installed Git and ripgrep (rg) via Scoop. However, I discovered that Codex ends up running on WSL. I traced this to the fact that I tried lowering that path’s priority in Yet, as I mentioned in my issue #3159 , Codex still calls WSL’s |
Beta Was this translation helpful? Give feedback.
-
I would be careful with git bash however, I have heard it causes problems with the Codex IDE plugin where it just fails to load without any obvious errors |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently Codex CLI on Windows isn't as great as it is on WSL but it is possible to configure the shell as bash and retain all the same benefits as Linux does and it doesn't even require WSL.
Quick summary
C:\msys64
).bash
to MSYS2’s bash.PATH
and add VS Code’sbin
.ripgrep
(rg
).bash -l
→ runcode .
orcodex
.1) Install MSYS2 (ucrt64)
Install MSYS2 (default location is
C:\msys64
). If you installed elsewhere (e.g.,D:\Software\MSYS2
), just swap paths accordingly below.2) Make PowerShell’s
bash
point to MSYS2Open your PowerShell profile (creates it if missing), then add the alias.
Note: This assumes you have VS Code installed, if you use another IDE swap out code with it (notepad/cursor/etc)
Add one of these lines (pick the path where you installed MSYS2):
Save, then in PowerShell run:
bash -l
3) Set up your MSYS2 bash PATH (ucrt64 first)
In the bash window, create/edit your profile:
nano ~/.bash_profile
Add this (default install path shown first). Keep the ucrt64/bin entry before usr/bin so tools come from ucrt64:
If you have the user installation version of VS Code, don't forget to replace ${USERNAME} with your actual user name on windows.
Save, then reload your profile:
4) Update MSYS2 and install
ripgrep
(rg)Open the MSYS2 UCRT64 shell (or just stay in this bash) and run:
Sanity checks:
5) Daily usage
bash -l
That’s all, launching VS Code (or Codex) from bash makes its terminals/tasks prefer bash commands, matching the Linux experience.
Tips & gotchas
If
code
isn’t found in bash, double-check that VS Code’sbin
folder is in thePATH
you added (…/Microsoft VS Code/bin
), thensource ~/.bash_profile
and try again.If you see the wrong
rg
or other tools, runwhich rg
and ensure the path points to/ucrt64/bin
. PATH order matters.You can make VS Code’s integrated terminal default to this bash by setting:
bash.exe
inC:\msys64\usr\bin\bash.exe
, then set it as default.Sometimes Codex will still try to use powershell commands, to fix that, update Agents.md file to say always run every command through bash -lc
Beta Was this translation helpful? Give feedback.
All reactions