Skip to content

Windows Codex app + WSL: UNC cwd breaks terminal, Windows config leaks into WSL, and worktrees need a WSL-native CODEX_HOME #18506

@blockedby

Description

@blockedby

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:

  1. The integrated terminal fails to open in the project directory when integratedTerminalShell is set to wsl.
  2. The app continues to use Windows-side config/state in WSL mode.
  3. 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 wslhere opens 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

  1. If a project path is a WSL UNC path, convert it to its Linux path before launching wsl.exe for the integrated terminal.
  2. In WSL mode, default the runtime CODEX_HOME / worktree root to a WSL-native location.
  3. Make it unambiguous which config file is active in WSL mode.
  4. If a full fix takes time, document the above workaround in official Windows + WSL guidance.

Related reports

These look closely related:

Happy to provide more exact local details if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingconfigIssues involving config.toml, config keys, config merging, or config updateswindows-osIssues related to Codex on Windows systems

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions