Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.130.0
What subscription do you have?
ChatGPT Plus via ChatGPT sign-in auth (auth_mode: chatgpt).
This startup stall happens before the first model request or tool call, so the plan tier does not appear to affect reproduction.
Which model were you using?
When I normally use Codex in this environment, I use gpt-5.4 with high reasoning effort.
For this specific bug, the stall occurs during interactive CLI startup before the first prompt/model request, so the model choice does not appear to affect reproduction.
What platform is your computer?
Ubuntu 22.04.2 LTS on WSL2:
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
Windows host:
Microsoft Windows NT 10.0.19045.0 x64
cmd.exe ver: Microsoft Windows [Version 10.0.19045.6456]
WSL component versions:
WSL 2.6.3.0
kernel 6.6.87.2-1
WSLg 1.0.71
What terminal emulator and version are you using (if applicable)?
Primary repro is in an interactive WSL shell with:
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
I also reproduced the same behavior under script(1) pseudo-TTY capture for strace, which suggests this is not specific to one terminal frontend.
What issue are you seeing?
Starting interactive Codex CLI from a WSL Linux cwd such as /home/... stalls for about 60 seconds before the UI becomes usable.
strace consistently shows Codex spawning:
cmd.exe /d /s /c "set TERM_PROGRAM"
during startup. When the launcher cwd is a WSL Linux path, that probe is followed by an approximately 60 second wait, and only after that do I see output referencing a \\wsl.localhost\\Ubuntu-22.04\\home\\... path and TERM_PROGRAM.
Control test:
- Launching the same unmodified Codex build from a Windows-backed cwd such as
/mnt/c/Windows/System32 - while still targeting the same Linux repo via
-C /home/...
does not show the equivalent 60 second stall.
Additional observation:
- Pre-setting
TERM_PROGRAM=foodoes not prevent thecmd.exeprobe. - Codex still executes
cmd.exe /d /s /c "set TERM_PROGRAM"and still stalls when launched from/home/....
Based on the traces, the practical trigger appears to be the cwd from which Codex is launched in WSL, not the workspace path eventually used by -C.
What steps can reproduce the bug?
Minimal repro:
- Install Codex CLI normally on WSL.
- Open a WSL shell in a Linux-backed directory such as:
cd /home/<user>/<repo>- Start interactive Codex:
codex --no-alt-screen- Observe that startup stalls for roughly 60 seconds before the UI becomes usable.
Control repro:
- From a Windows-backed cwd instead, for example:
cd /mnt/c/Windows/System32- Start the same Codex build, but point it back at the same Linux repo:
codex -C /home/<user>/<repo> --no-alt-screen- Observe that the equivalent ~60 second stall does not occur.
Instrumented repro used for trace capture:
CODEX_JS="$(npm root -g)/@openai/codex/bin/codex.js"
cd /home/<user>/<repo>
timeout 75s strace -f -ttT -o home_launch.strace \
script -q -c "node $CODEX_JS --no-alt-screen" /dev/null
cd /mnt/c/Windows/System32
timeout 20s strace -f -ttT -o windows_cwd_launch_home_C.strace \
script -q -c "node $CODEX_JS -C /home/<user>/<repo> --no-alt-screen" /dev/nullRepresentative trace lines from the slow /home/... launch:
execve("/mnt/c/Windows/system32/cmd.exe",
["cmd.exe", "/d", "/s", "/c", "set TERM_PROGRAM"], ...)
...
<... poll resumed>) = 1 ([{fd=8, revents=POLLIN}]) <60.024460>
read(7, "'\\\\wsl.localhost\\Ubuntu-22.04\\ho"..., 4096) = 158
Representative trace lines from the control launch from /mnt/c/...:
execve("/mnt/c/Windows/system32/cmd.exe",
["cmd.exe", "/d", "/s", "/c", "set TERM_PROGRAM"], ...)
but no corresponding \\wsl.localhost\\... output and no matching ~60 second wait in the same probe path.
What is the expected behavior?
Interactive Codex startup on WSL should not block for ~60 seconds just because the launcher cwd is a Linux path such as /home/....
If Codex needs terminal detection in WSL, I would expect one of these behaviors instead:
- Use a Linux-native probe in WSL rather than spawning
cmd.exe - Or launch the Windows helper with a safe Windows cwd
- Or skip the probe when
TERM_PROGRAMis already present
Additional information
Observed facts from my local traces:
cmd.exe /d /s /c "set TERM_PROGRAM"is executed during startup- the slow path reproduces when Codex is launched from
/home/... - the slow path does not reproduce in the same way when Codex is launched from
/mnt/c/...and given-C /home/... - pre-setting
TERM_PROGRAM=foodoes not suppress thecmd.exeprobe - I reproduced this on the current installed CLI here:
codex-cli 0.130.0 - before drafting this report, I searched for related WSL / UNC /
cmd.exe/TERM_PROGRAMissues and did not find a clear exact duplicate for this specific CLI startup stall
Practical workaround:
cd /mnt/c/Windows/System32
codex -C /home/<user>/<repo> --no-alt-screenI also have a local shell-level workaround that temporarily shadows cmd.exe, but I am intentionally not leading with that because the simpler control above already isolates the issue enough.
Related reports that seem adjacent but not identical:
- Windows Codex app + WSL: UNC cwd breaks terminal, Windows config leaks into WSL, and worktrees need a WSL-native CODEX_HOME #18506
- Windows desktop in WSL mode uses the Windows CODEX_HOME inside WSL and creates/stores worktrees on /mnt/c instead of the WSL filesystem #13762
- Windows Codex cannot start when WSL mode is enabled (terminalShell=wsl) #14461
If useful, I can attach sanitized trace snippets or provide a smaller reproducer script.
Activity
novcky commentedon May 22, 2026
I can confirm the same startup stall from a separate WSL2 environment on a newer CLI version.
Environment:
The behavior matches this report:
From a Windows-backed cwd, the same command is fast:
And this avoids the Codex startup delay while keeping the same project directory:
cd /mnt/c codex --cd /root/projects/github/Aetherstraceconfirms the startup delay is in the Windows interop request:Two additional observations:
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codexstill triggers thecmd.exe /d /s /c set TERM_PROGRAMprobe.TERM_PROGRAM=Windows_Terminalalso does not prevent the Windows-side probe.Based on
codex-rs/tui/src/tui/keyboard_modes.rs, a low-risk fix could be:CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENTbefore any VS Code / Windows-side terminal detection is attempted.TERM_PROGRAMwhen it is already present, especiallyTERM_PROGRAM=vscode, before falling back to Windows interop./mnt/c/Windows/System32if it exists, so WSL does not pass a\\wsl.localhost\...cwd to Windows.I can help test a focused fix on this affected WSL setup if needed.
zaaack commentedon Jun 13, 2026
Same here. Thanks for the comment upstairs. I wrote an alias to bypass this bug, but exiting the cli is still very slow.
Acheatcn commentedon Aug 10, 2026
Still reproducible on the latest stable Codex CLI version available in my environment:
0.147.0.Environment:
codex doctor --json:overallStatus: ok0.147.0as the latest/current versionRepresentative timings from
strace:etraut-openai commentedon Oct 12, 2026
(response from codex)
Closing as fixed by #45811 in CLI v0.162.1. The Windows TERM_PROGRAM probe in WSL now has a one-second deadline including slow launch, caches timeouts and cleans up the child. A blocked probe should no longer hold startup for about a minute.