WSL CLI cannot share Windows Codex App CODEX_HOME: migration 1 was previously applied but has been modified
What version of Codex is running?
- Windows Codex App:
26.513.4821.0 - WSL Codex CLI before alignment:
0.131.0-alpha.22 - WSL Codex CLI after aligning to the Windows App bundled Linux runtime:
0.131.0-alpha.9 - The Linux runtime bundled inside the Windows App package also reports:
codex-cli 0.131.0-alpha.9
Platform
- Windows:
Microsoft Windows NT 10.0.26200.0 - WSL:
2.6.3.0 - Distro:
Ubuntu-24.04 - Ubuntu:
24.04.4 LTS - Kernel:
6.6.87.2-microsoft-standard-WSL2
What issue are you seeing?
The Windows + WSL documentation says WSL CLI can share config/auth/sessions with the Windows Codex App by setting:
export CODEX_HOME=/mnt/c/Users/<windows-user>/.codex
However, when WSL Codex CLI starts with CODEX_HOME pointing at the Windows App Codex home, startup fails before creating a session:
Codex couldn't start because its local database appears to be damaged.
Technical details:
Location: /mnt/c/Users/<windows-user>/.codex/state_5.sqlite
Cause: failed to initialize state runtime at /mnt/c/Users/<windows-user>/.codex: migration 1 was previously applied but has been modified
Repair Codex local data now? [y/N]:
I did not accept the repair prompt because this is the Windows Codex App's live state database.
Steps to reproduce
- Install and use the Codex Windows App.
- Confirm the Windows App has a Codex home at:
C:\Users\<windows-user>\.codex
- In WSL, set:
export CODEX_HOME=/mnt/c/Users/<windows-user>/.codex
- Start Codex CLI from WSL:
codex --no-alt-screen -C /home/<wsl-user> "test"
- Observe:
migration 1 was previously applied but has been modified
- Align the WSL CLI to the Linux runtime bundled with the Windows App:
npm install -g @openai/codex@0.131.0-alpha.9
codex --version
# codex-cli 0.131.0-alpha.9
- Retry with
CODEX_HOME=/mnt/c/Users/<windows-user>/.codex.
Actual result: the same migration mismatch occurs.
I also tested against a copy of the Windows .codex directory instead of the live one; the same error occurs. SQLite integrity check on the copied Windows state_5.sqlite returns ok.
Expected behavior
One of these should happen:
- WSL Codex CLI should be able to open the Windows App
CODEX_HOMEas documented, or - The documentation should clarify that a Windows-created
state_5.sqlitecannot be shared with the Linux/WSL runtime, or - Codex should detect this as a cross-runtime migration/checksum mismatch and show a non-destructive, explicit message instead of suggesting a repair of the Windows App database.
Actual behavior
WSL Codex CLI treats the Windows App state_5.sqlite as a damaged/mismatched database and offers to repair it. This is risky because the DB belongs to the Windows Codex App and appears valid from the Windows side.
Additional notes
Windows App state DB integrity check:
PRAGMA integrity_check;
ok
Windows App thread count remained stable after the cancelled test:
SELECT count(*) FROM threads;
130
No config.toml, auth files, tokens, local project paths, or session contents are included here.
Possibly related:
8 Comments
Looks like there's a fix in the works, but in the meantime I was able to do the following as a workaround - the sql lite file locations default to the main
.codexdirectory, but if you make them their own directory and then assign the new path to a variable, it seems to allow codex to use them from WSL correctly. This involved setting a WSL env variable and a TOML variable - not sure if both are required, but this is what worked for me.I am using a company-managed laptop (no admin access) with windows 11 and WSL Ubuntu 2
~\.bashrcfile in nano or whatever and setCODEX_HOMEto/mnt/c/Users/<user_name>/.codexCODEX_SQLITE_HOMEto/mnt/c/Users/<user_name>/.codex/sqlite-wsl.codexand backup all your existing .sqlite files, create a new folder calledsqlite-wslFair warning - even after starting, I had to do a bit more fiddling to get a terminal session running, and I had to manually install bubblwrap in WSL for some reason:
life savior
This is now covered by the same CRLF/LF SQLx checksum root cause tracked in #23777 and #23787. A Windows-created Codex App
CODEX_HOMEcan contain CRLF-hashed migration rows, while the WSL/Linux backend expects LF-hashed rows and refuses to open the samestate_5.sqlite/logs_2.sqlite.I published a non-destructive recovery toolkit here: https://github.com/xdifu/codex-repair
Windows PowerShell / Windows Terminal:
If you run it from WSL bash to repair Windows Codex Desktop data, pass
--codex-home "/mnt/c/Users/<WindowsUser>/.codex"so it does not target WSL's own~/.codex.It auto-detects the active backend binary, extracts the expected migration checksums, verifies the live schema before any update, backs up both SQLite DBs, and preserves
sessions/*.jsonlas read-only. This is meant as a safer alternative to moving/deleting the DBs or accepting the destructive repair prompt.@xdifu Brilliant, worked flawless here, thank you!
@thollands thank you!
@thollands your solution can work well with cc-switch ! thank you !
I am seeing a very similar Windows/WSL state failure today, now through the VS Code Codex extension as well as Desktop/CLI sharing.
Environment:
1904522.04.5 LTS, kernel6.6.114.1-microsoft-standard-WSL2OpenAI.Codex 26.519.3891.0openai.chatgpt@26.519.32039codex --version:codex-cli 0.133.0-alpha.1/mnt/c/Users/<user>/.codexVS Code Codex is stuck on the loading screen. Its extension log shows:
I also hit a related Desktop/CLI reliability problem yesterday after a Codex Desktop auto-update involving bundled binary/runtime mismatch and backfill-timeout behavior. Today, Desktop is still technically responding, but trivial prompts on fast mode with
gpt-5.5/ medium reasoning / priority service tier are taking 25-63s per turn, while VS Code Codex is blocked by the migration mismatch above.This strongly suggests the Windows app, VS Code extension, and WSL CLI can still get into incompatible runtime/state combinations when sharing
CODEX_HOME, and the failure mode leaves the VS Code extension stuck loading rather than presenting a non-destructive recovery path.Follow-up with a more controlled timing matrix from the same Windows/WSL machine, after the VS Code loading-screen failure was locally recovered.
Environment:
OpenAI.Codex 26.519.3891.0openai.chatgpt@26.519.32039codex-cli 0.133.0-alpha.1Observed split:
helloaround 2-4s, factual query around 6-8s.helloaround 18s, trivial/factual turns around 38s in one fresh chat.Controlled CLI timings for
Reply exactly: <probe>-pong:| Probe | Result |
| --- | ---: |
| WSL CLI, Desktop env / Windows-backed Codex home | 39.257s |
| WSL CLI, same env,
--disable plugins --disable apps| 10.868s || WSL CLI, Linux-side Codex home | 4.823s |
| WSL CLI, Linux-side Codex home,
--disable plugins --disable apps| 3.092s || Existing Windows
codex.exefrom VS Code extension | 9.208s || Existing Windows
codex.exe,--disable plugins --disable apps| 3.665s |Temporary mitigation applied locally:
After that, normal WSL CLI probes from the Desktop environment improved to:
gpt-5.4: 9.665sgpt-5.5: 7.610sThe plugin catalog 403/Cloudflare challenge warnings disappeared after disabling apps/plugins, but
codex_rollout::list ... state db discrepancy ... falling_backwarnings remain. This seems to be two overlapping issues: plugin/app startup work causing large latency spikes, and Windows/WSL Codex-home/state behavior causing fallback/migration problems.