Windows Codex app + WSL: UNC cwd breaks terminal, Windows config leaks into WSL, and worktrees need a WSL-native CODEX_HOME
Summary
On Windows Codex Desktop with a repository opened from WSL via a UNC path such as:
\\?\UNC\wsl.localhost\Ubuntu-24.04\home\<user>\project
there are three related problems in practice:
- The integrated terminal fails to open in the project directory when
integratedTerminalShellis set towsl. - The app continues to use Windows-side config/state in WSL mode.
- Worktrees need to live on the WSL filesystem, not under
C://mnt/c, otherwise performance becomes unacceptable.
I am filing this as a consolidated issue because the current user experience pushes teams into ad-hoc workarounds, and a documented workaround would already help a lot.
Environment
- Date observed: April 18, 2026
- Platform: Windows 11 + WSL2
- Distro: Ubuntu-24.04
- Repo location:
/home/<user>/...inside WSL - Project opened in Codex Desktop through
\\wsl.localhost\Ubuntu-24.04\home\<user>\...
Problem 1: integrated terminal in WSL mode loses the project cwd
When the project is opened from a WSL UNC path, Codex Desktop appears to pass a Windows UNC path such as:
\\?\UNC\wsl.localhost\Ubuntu-24.04\home\<user>\project
into wsl.exe as the cwd.
In practice, this produces:
wsl: Failed to translate '\\?\UNC\wsl.localhost\Ubuntu-24.04\home\<user>\project'
and the terminal falls back to ~ instead of opening in the repo directory.
Expected behavior
If the project root is inside WSL, the terminal should open directly in the matching Linux directory, e.g.:
/home/<user>/project
Actual behavior
The terminal drops into home, and users need to manually cd back or use a custom wrapper.
Problem 2: Windows config/state still leaks into WSL mode
Even in WSL mode, the app can still reference Windows-hosted config.toml / state instead of the WSL-native location.
This creates confusion about which config is actually active and makes sharing MCP / terminal setup across teammates much harder.
Problem 3: worktrees must live inside WSL
When CODEX_HOME points at the Windows location, worktrees can end up under /mnt/c/Users/<user>/.codex/... instead of a Linux-native directory.
That is a major performance problem for Git-heavy workflows. In real usage, teams keeping repos in WSL want worktrees under something like:
/home/<user>/.codex-app/worktrees/...
not on the Windows filesystem.
Practical workaround that worked for us
1. Keep the agent in WSL, but set the integrated terminal back to PowerShell
Using integratedTerminalShell = "wsl" is the part that breaks terminal startup for UNC-backed WSL repos.
Switching the integrated terminal back to powershell avoids the broken cwd translation path.
2. Force a WSL-native CODEX_HOME only for Codex Desktop
In ~/.profile inside WSL:
# Keep Codex Desktop state/worktrees on the Linux filesystem when the
# Windows app launches its WSL runtime.
if [ "${CODEX_INTERNAL_ORIGINATOR_OVERRIDE:-}" = "Codex Desktop" ]; then
export CODEX_HOME="$HOME/.codex-app"
fi
Then create the directory once:
mkdir -p ~/.codex-app/worktrees ~/.codex-app/sessions ~/.codex-app/tmp
This keeps worktrees and internal Codex state on the Linux filesystem, which is much faster for WSL-hosted repos.
3. Add a PowerShell helper that jumps from the current UNC path into WSL in the same directory
In the Windows PowerShell profile:
function Enter-WslHere {
param(
[string]$Path = (Get-Location).Path
)
$p = $Path -replace '^\\\\\?\\UNC\\', '\\'
if ($p -match '^\\\\wsl(?:\.localhost)?\\([^\\]+)\\(.+)$') {
$distro = $matches[1]
$linuxPath = '/' + ($matches[2] -replace '\\', '/')
wsl.exe -d $distro --cd $linuxPath
return
}
Write-Error "Current path is not a WSL UNC path: $Path"
}
Set-Alias wslhere Enter-WslHere
This gives a reliable bridge:
- Codex integrated terminal opens as PowerShell in the project UNC path
- running
wslhereopens WSL in the matching Linux project directory
Why this matters
For teams developing in WSL, the current behavior makes the Windows app feel half-configured even when the repo is already correctly placed inside Linux.
The desired setup is straightforward:
- repo in WSL
- agent in WSL
- worktrees in WSL
- terminal opens in the exact project directory
Today, that still requires manual tweaks and user-discovered workarounds.
Requested improvements
- If a project path is a WSL UNC path, convert it to its Linux path before launching
wsl.exefor the integrated terminal. - In WSL mode, default the runtime
CODEX_HOME/ worktree root to a WSL-native location. - Make it unambiguous which config file is active in WSL mode.
- If a full fix takes time, document the above workaround in official Windows + WSL guidance.
Related reports
These look closely related:
- #13549
- #13762
- #14461
Happy to provide more exact local details if useful.
10 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This is a try of workaround. but not a bug report, so it is only partially related
I am seeing what looks like the same class of bug from a different host setup: macOS Codex Desktop connecting remotely to both Windows and WSL over SSH.
Environment
winandwsl), but they are actually tied to the same physical computer / user environmentI do not know if this is the exact same root cause as the UNC cwd case in this issue, but the symptom pattern is very similar: Windows/WSL path and state leakage across host boundaries.
What I observed
1. Windows remote sometimes shows the WSL directory / project binding
When I connect to the Windows remote and start/open a project there, Codex can end up showing a WSL directory or otherwise behave as if the active workspace binding came from the WSL host.
In practice, the Windows side appears to get “contaminated” by the WSL-side project mapping.
2. Windows remote task creation can fail with:
Invalid request: AbsolutePathBuf deserialized without a base pathThis happened while opening a Windows-side conversation/project.
3. Logs suggest WSL paths are being handled while the selected host is Windows
From the macOS Desktop logs, I saw Windows-side activity mixed with WSL-style paths. For example, the app was trying to watch or resolve git paths like
/home/...or\home\...while the selected remote host was the Windows remote.That strongly suggests stale or leaked workspace/cwd/git-watcher state across remote hosts.
4. Auth state also drifted separately across the remote hosts
I also hit the related remote auth problem where WSL-side Codex was still using stale auth state even though local/macOS auth had already refreshed. Syncing auth fixed WSL, but the Windows/WSL workspace-binding issue remained a separate problem.
So in my case there seem to be two layers:
What made this especially suspicious
A local restore of the macOS-side Desktop state file:
~/.codex/.codex-global-state.jsontemporarily fixed the Windows-vs-WSL remote mapping.
That makes this look less like a project-specific problem and more like a Desktop-side remote-project / workspace-binding state corruption issue.
Why I think this is related to this issue
This issue describes Windows/WSL boundary problems where:
My setup is different because the host app is macOS, but the underlying failure mode seems closely related:
Practical takeaway
Even when the app is not running on Windows directly, Codex Desktop appears fragile when both of these are present at the same time:
I don't know if this is the right solution or not, but frankly working with the app in WSL is still something of a nightmare. In our case the main issue is that diffs are broken.
honestly, I moved off to other agent harness, and installed kubuntu as daily driver =)
Probably related: I just installed the Codex App today (26.422.30944), to use on my repos in WSL. As shown in this image, I was able to set the agent environment to WSL, but the integrated terminal shell won't let me select WSL. It seems frozen on PowerShell. And probably as a result of that, when I ask Codex to run a Git command it tries to use Git from PowerShell instead of WSL Git, which leads to errors.
<img width="866" height="511" alt="Image" src="https://github.com/user-attachments/assets/a76f240f-aa18-4048-a1f8-7264e437ca08" />
I can reproduce the Windows-side CODEX_HOME behavior on Codex Desktop for Windows with WSL mode enabled. This was generated by Codex:
Environment:
What I observed:
/mnt/c/Users/<user>/.codex/bin/wsl/codex app-server --analytics-default-enabled/mnt/c/Users/<user>/.codexWhat improved it:
CODEX_HOME=/home/<user>/.codex-app/home/<user>/.codex-app/home/<user>/...instead of:
/mnt/c/...After this, startup felt much better.
I also found a separate local shell startup issue in my own
~/.bashrc, so I am not treating that part as a Codex bug. The Codex-specific issue appears to be that WSL mode inherits the Windows-side CODEX_HOME, which pushes runtime state/worktree-related paths onto/mnt/c.Additional current evidence from Windows Desktop + WSL mode:
OpenAI.Codex_26.506.3741.0_x64__2p2nqsd0c76g02.7.3.0, kernel6.6.114.1-1/mnt/c/Users/<user>/.codex/bin/wsl/codexCODEX_HOME=/mnt/c/Users/<user>/.codexC:\Users\<user>\.codex\\wsl.localhost\Ubuntu\home\<wsl-user>\...The WSL IO performance toast appears on app launch, regardless of which project is later selected, because the WSL app-server/runtime starts from the Windows-mounted Codex home and cwd. Repos can be correctly placed under
/home/<wsl-user>/..., but runtime/cache/tmp/helper paths are still under/mnt/c/Users/<user>/.codex.I tested the
CODEX_INTERNAL_ORIGINATOR_OVERRIDE=Codex Desktop+CODEX_HOME=/home/<wsl-user>/.codex-appworkaround. It is directionally correct for IO/worktree performance, but I reverted it because it creates a risky split-brain state between Windows Desktop UI/config and WSL app-server runtime/config. This really needs a first-class product setting or default split between Windows UI state and WSL-native runtime/worktree/cache roots.Same issue here on Windows. Since WSL is the main reason I want to use the desktop app, this makes the app pretty hard to use reliably. Would really appreciate a fix.
Additional sanitized reproduction on a current Windows Store build:
Desktop persisted three WSL repositories in
electron-saved-workspace-rootsas UNC values:I tested replacing one saved root with its canonical POSIX value:
For ten minutes after the edit:
EISDIRwatcher event appeared;After changing a second root to POSIX, Desktop rewrote its in-memory workspace state back to disk and restored all three UNC values, including the first root that had passed the ten-minute canary.
This suggests the problem is not only initial UNC-to-WSL conversion. Desktop also retains an authoritative in-memory representation and can overwrite canonical POSIX paths written to
.codex-global-state.json.Expected behavior:
/home/...paths when the app-server runs in WSL;No repository or worktree corruption occurred during this test. The test was stopped as soon as the UNC values returned.