Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.130.0
What subscription do you have?
ChatGPT account
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 6.6.114.1-microsoft-standard-WSL2 x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
Windows Terminal running a WSL Ubuntu profile
Codex doctor report
not availableWhat issue are you seeing?
When launching codex interactively from WSL, the terminal stays blank for about 60 seconds before the Codex TUI draws anything.
This happens immediately after pressing Enter on codex, before normal session initialization appears in ~/.codex/log/codex-tui.log.
I narrowed it down to Codex's WSL terminal detection path. Codex appears to call:
cmd.exe /d /s /c "set TERM_PROGRAM"
On this machine, that command takes about 61 seconds when run from a WSL Linux working directory:
/usr/bin/time -f elapsed=%e timeout 75 cmd.exe /d /s /c "set TERM_PROGRAM"
Output:
'\wsl.localhost\Ubuntu-24.04\home<user>\codex'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Environment variable TERM_PROGRAM not defined
Command exited with non-zero status 1
elapsed=61.05
During the blank period, Codex has only emitted initial terminal mode output such as bracketed paste enablement. The TUI has not drawn yet.
A local workaround confirms the cause: putting a narrow cmd.exe shim first in PATH only for codex, which immediately responds to cmd.exe /d /s /c "set TERM_PROGRAM", makes Codex draw the UI within a few seconds.
What steps can reproduce the bug?
-
Use Windows Terminal with a WSL2 Ubuntu profile.
-
Install and authenticate Codex CLI.
-
Open WSL in a Linux filesystem directory, for example:
cd ~/codex
-
Run:
codex
-
Observe that the terminal is blank for about 60 seconds before the TUI appears.
To isolate the underlying slow probe, run:
/usr/bin/time -f elapsed=%e timeout 75 cmd.exe /d /s /c "set TERM_PROGRAM"
In this environment it takes about 61 seconds.
I also tested these nearby mitigations:
codex --no-alt-screen
codex --no-alt-screen --disable terminal_resize_reflow
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex --no-alt-screen
TERM_PROGRAM=Windows_Terminal codex --no-alt-screen
None of those avoided the startup blank period in this setup.
What is the expected behavior?
Codex should not block TUI startup for around a minute while probing Windows-side TERM_PROGRAM from WSL.
Possible fixes:
- Put a short timeout around the cmd.exe /d /s /c "set TERM_PROGRAM" probe.
- Skip the Windows-side probe unless it is strictly needed.
- Honor CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 before calling the WSL cmd.exe probe.
- Prefer Linux-side TERM_PROGRAM when set and avoid Windows interop when unset.
Unsupported or slow terminal detection should fall back quickly and draw the UI.
Additional information
This looks related to the WSL/Windows interop class of issues, but I did not find an exact duplicate for this startup path.
Related but not identical:
- Codex is unable to run .exe files using WSL session #7886
- CLI startup has a fixed ~15s
session_init.auth_mcpdelay with custom localhost provider and API-key auth whenrequires_openai_auth = true#17531
The relevant source path appears to be:
codex-rs/tui/src/tui/keyboard_modes.rs
Specifically, read_windows_term_program() calls:
std::process::Command::new("cmd.exe")
.args(["/d", "/s", "/c", "set TERM_PROGRAM"])
Activity
earonesty commentedon Jul 7, 2026
THANK YOU!
my workaround:
cmd.exe is so busted in wsl, it's never a good idea to run it anyway
WilliamK7 commentedon Sep 13, 2026
Follow-up: this still affects Codex CLI 0.154.0. After upgrading from 0.153.4, the long blank period before the first TUI frame returned because the PATH-based workaround in the original report stopped being used.
What changed in the observed startup path
Comparing the installed Linux binaries with
strace:cmd.exeshim placed first in PATH.The delay occurs after initial terminal mode output (e.g. bracketed paste enablement), before visible UI. Setting
TERM_PROGRAM=Windows_TerminalorCODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1still does not reliably skip this Windows probe. Its duration varies, so a single fast launch with those variables is not evidence that the probe was avoided.Current environment: Ubuntu 24.04 on WSL2, Windows Terminal, x86_64 Linux standalone Codex 0.154.0; kernel
6.18.33.2-microsoft-standard-WSL2.Updated local workaround, verified on 0.154.0
A narrow shim at
/usr/local/bin/cmd.exeis found by the new executable resolution path. It answers only the exact/d /s /c "set TERM_PROGRAM"probe when the parent executable is Codex; all other calls are forwarded to the real Windowscmd.exewith unchanged arguments.In an isolated PTY test with the unmodified 0.154.0 binary and a temporary unauthenticated CODEX_HOME, tracing confirmed execution of this shim instead of the Windows binary, and the welcome screen appeared in approximately 0.58 seconds. That measures terminal initialization, not authenticated session/model loading. Forwarding behavior and exit-status preservation were also checked separately.
I then installed the shim and confirmed that normal interactive startup on my actual machine is fast again, without downgrading Codex.
This is a local workaround, not an upstream fix. The existing user-PATH workaround (including the one in the preceding comment) no longer covers this startup path on my 0.154.0 installation. Could the Windows terminal probe have a short bounded timeout / fast fallback, or run without blocking the first UI frame? That would address the underlying issue while retaining the newer executable-resolution behavior.
etraut-openai commentedon Oct 12, 2026
Closing as tracked in #22176: both reports isolate the roughly 60-second WSL startup stall to the cmd.exe TERM_PROGRAM probe from a Linux working directory. The later version findings here are useful there; please follow that issue.
/home/...stalls ~60s incmd.exeset TERM_PROGRAMprobe #22176