You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL agent environment corrupts local state_5.sqlite migration on Windows #23841
Deleting the .codex directory also reset the agent environment setting from WSL back to Windows Native. But to be clear, that was just a workaround to get it launching again, not a proper fix for the underlying issue.
This looks like the same CRLF/LF SQLx checksum mismatch tracked in #23777 and #23787. Switching a Windows-created CODEX_HOME to the WSL backend can make the Linux binary expect LF-hashed migrations while the existing SQLite DB has CRLF-hashed _sqlx_migrations rows. Deleting .codex gets the app launching again, but it loses the existing local history metadata.
git clone https://github.com/xdifu/codex-repair.git
cd codex-repair
python codex-repair.py doctor
python codex-repair.py fix --apply
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 extracts the expected checksums from the active Codex backend binary, schema-verifies before any write, backs up state_5.sqlite / logs_2.sqlite, and can also finish the state backfill outside the 30s GUI timeout. sessions/*.jsonl stays read-only.
Reacted by Nick Neely
Reacted by Han Moe Htet, Daiki Hashimoto and let-me-cook
Activity
github-actions commentedon May 21, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
migration 1 was previously applied but has been modified#23824Powered by Codex Action
ibdevio commentedon May 21, 2026
same problem
any fixes?
daikihashimoto95 commentedon May 21, 2026
Deleting the .codex directory and restarting Codex fixed the startup issue for me, but it also wiped all local chat history.
At the moment I don't know a way to recover/fix the migration issue while preserving the existing chat history database.
ibdevio commentedon May 21, 2026
but deleting .codex directory changes WSL to Windows Native as well
daikihashimoto95 commentedon May 21, 2026
You're right. I forgot to mention that.
Deleting the
.codexdirectory also reset the agent environment setting from WSL back to Windows Native. But to be clear, that was just a workaround to get it launching again, not a proper fix for the underlying issue.sabruss commentedon May 21, 2026
when i perform an app refresh on a fresh .codex directory to allow wsl again it crash again with the same issue
lim-0 commentedon May 21, 2026
same issue
ibdevio commentedon May 21, 2026
yeah. same
sabruss commentedon May 21, 2026
I may have found a temporary workaround.
First, install the Codex CLI package wsl side:
Then set the CODEX_HOME environment variable so it points to the Windows .codex directory and run codex
CODEX_HOME=/mnt/c/Users/username/.codex codexCodex should detect the corrupted database and repair it.
Once the repair is complete, the Codex app should be able to run with WSL support again.
ChouUn commentedon May 21, 2026
@sabruss it works, thx.
btw, we can run
CODEX_HOME=/mnt/c/Users/username/.codex codexin one line to avoid the restarting.sunbin998 commentedon May 21, 2026
thank you. it works.
jshaofa-ui commentedon May 21, 2026
Technical Solution for WSL State Corruption
Root Cause
NOT actual database corruption — it is a CRLF/LF line ending mismatch in SQLx migration checksums:
\r\n) line endings\n) line endingssha384(CRLF) != sha384(LF)Proposed Fix (4-part)
.gitattributes+normalize_migration_sql()to ensure consistent line endingsCode Changes
.gitattributes: Add* text=auto eol=lffor SQL filescrates/codex-sqlx/src/migration.rs: Addnormalize_migration_sql()+ checksum repaircrates/codex-app/src/db.rs: Add per-environment DB pathTest Plan
Impact
Full solution:
solutions/codex-23841-wsl-agent-corrupts-state-sqlite-fix.mdxdifu commentedon May 21, 2026
This looks like the same CRLF/LF SQLx checksum mismatch tracked in #23777 and #23787. Switching a Windows-created
CODEX_HOMEto the WSL backend can make the Linux binary expect LF-hashed migrations while the existing SQLite DB has CRLF-hashed_sqlx_migrationsrows. Deleting.codexgets the app launching again, but it loses the existing local history metadata.For a non-destructive recovery path, I published a small Apache-2.0 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 extracts the expected checksums from the active Codex backend binary, schema-verifies before any write, backs up
state_5.sqlite/logs_2.sqlite, and can also finish the state backfill outside the 30s GUI timeout.sessions/*.jsonlstays read-only.Soulsolder commentedon May 21, 2026
it's actually logs_2.sqlite
solved here:
#23863