[Windows][WSL] MSIX EFS-encrypted bundled codex fails relocation with ERROR_ENCRYPTION_FAILED (0x80071770)
What version of the Codex App are you using?
ChatGPT/Codex Windows package 26.810.4967.0; bundled CLI codex-cli 0.148.0-alpha.9.
What platform is your computer?
- Microsoft Windows NT
10.0.26200.0x64 - Microsoft Store / MSIX package
OpenAI.Codex - WSL
2.7.11.0, Ubuntu 22.04, kernel6.18.33.2-microsoft-standard-WSL2
What issue are you seeing?
After enabling the WSL agent and restarting, the app can fail with:
Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the
Electron resources include bin/codex.
The Linux binary is present at app\resources\codex. The failure occurs while the app relocates the bundled Linux executables from the protected WindowsApps package into %USERPROFILE%\.codex\bin\wsl\<hash>.
The source is marked Archive, Encrypted. Reproducing the copy directly gives:
$src = (Get-AppxPackage OpenAI.Codex).InstallLocation + '\app\resources\codex'
Copy-Item -LiteralPath $src -Destination "$env:TEMP\codex-copytest" -Force
The specified file could not be encrypted.
HRESULT: 0x80071770 (ERROR_ENCRYPTION_FAILED / Win32 error 6000)
The destination staging root is created but remains empty after the failed relocation. Windows-native mode works because it uses resources\codex.exe in place and does not perform this copy.
What steps can reproduce the bug?
- Install the Microsoft Store build whose
app\resources\codexhas theEncryptedattribute. - Select WSL as the agent environment and restart the app.
- Observe the missing-CLI startup error.
- Check
%USERPROFILE%\.codex\bin\wsl; the expected staging directory is absent or empty. - Run the PowerShell copy test above and observe
0x80071770.
Current workaround
Pre-stage decrypted copies of codex, codex-code-mode-host, and rg in the hash directory expected by the app:
- Read each packaged file with
File.OpenReadand write it withFile.Createso the destination does not inherit EFS/Application Protected encryption. - Verify file size and SHA-256 against the packaged sources.
- Place the files under
%USERPROFILE%\.codex\bin\wsl\<descriptor-hash>and restart the app.
This works: the staged codex starts successfully inside WSL and reports codex-cli 0.148.0-alpha.9. However, every app update changes the bundled binary hashes and therefore the expected directory, so the workaround must be repeated.
What is the expected behavior?
The app should relocate Application Protected/EFS-encrypted package resources to an unencrypted user directory, for example by using a copy path equivalent to COPY_FILE_ALLOW_DECRYPTED_DESTINATION, and should surface the underlying Win32 error instead of reporting that the CLI is missing.
Additional information
This appears to be the WSL CLI variant of the same protected-file relocation problem reported in #25220 and #34764. Related WSL startup reports include #28086, #30094, and #36777, but those reports do not identify ERROR_ENCRYPTION_FAILED during the bundled Linux CLI copy.
No WindowsApps permissions, ownership, package files, or encryption settings were modified.
8 Comments
I maintain WinBridge Recovery, an independent Windows recovery/diagnostic project for Codex Desktop local plugin/runtime state: https://github.com/zemeng5208/winbridge-recovery
This report is a very close match to the same Windows local-copy failure class WinBridge has been built around: protected MSIX/WindowsApps resources are readable/hashable, but normal relocation into a per-user staging directory fails because the source carries Application Protected / EFS semantics. The useful local layer to inspect here is specifically the packaged source attributes plus the generated
%USERPROFILE%\.codex\bin\wsl\<hash>staging target (including partial/empty staging left after a failed copy), not account/rollout state.WinBridge can help diagnose this class of local state drift and, where its current recovery path applies, rebuild user-writable copies from the already-installed official package with verification rather than modifying
WindowsApps. It also verifies package/version/hash changes so stale staged content is not silently reused after an update.A limitation worth making explicit: WinBridge's published primary scope is Browser / Chrome / Computer Use recovery, so I would not treat it as a guaranteed fix for this WSL CLI relocation path. If the Desktop build itself always retries the WSL copy with a method that cannot create a decrypted destination, the durable fix still belongs upstream (for example a
COPY_FILE_ALLOW_DECRYPTED_DESTINATION-equivalent path and reuse of a verified existing staged copy). It also does not change WindowsApps ownership, ACLs, or encryption policy.The
0x80071770 / ERROR_ENCRYPTION_FAILEDreproduction in this issue is especially useful because it distinguishes a package-protection copy failure from a genuinely missingresources\codexbinary.On Windows x64
26.820.7780.0, this Application Protected /ERROR_ENCRYPTION_FAILEDrelocation problem is no longer limited to the WSL CLI. The new build first requires relocation of the Windows-nativecodex.exe; when that fails, the entire desktop app exits during bootstrap.I added a complete, successfully recovered case at https://github.com/openai/codex/issues/40700#issuecomment-5419391502. It materializes verified per-user copies of all startup-time relocation resources from the currently installed official package: Windows CLI,
cua_node, Windowsrg, WSL CLI, and WSLrg. Afterward, the app started successfully and both the local and WSL app servers reachedinitialized=true / connected.This confirms that the WSL workaround documented here is directionally correct, but
26.820must cover all startup-time relocation resources; restoring only%USERPROFILE%\.codex\bin\wslis no longer sufficient. The linked comment includes the current directory IDs, recovery script, safety boundaries, and before/after validation.Because the complete procedure is relatively involved, the simplest option when the ChatGPT desktop app cannot start is to give that comment permalink to a working Codex CLI on Windows or WSL, or to a ChatGPT desktop session running inside WSL. The agent should verify the installed version and logs first, and only then perform and validate the recovery.
I can reproduce the same issue on a newer Codex Windows build, 26.820.7780.0, so this appears to still be unresolved in 26.820.
Environment:
Observed behavior:
"Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex."
"Attributes: Archive, Encrypted"
"Copy-Item -LiteralPath "$pkg\app\resources\codex" -Destination "$env:TEMP\codex-copytest" -Force"
fails with:
"Copy-Item : The specified file could not be encrypted."
("无法加密指定的文件" on my localized Windows installation)
I also confirmed that reading the encrypted packaged "codex" with "System.IO.File.ReadAllBytes()" and writing it to a normal user directory produces an unencrypted copy ("Attributes: Archive"), further suggesting that the failure is specifically related to relocation/copying of the Application Protected/EFS-encrypted MSIX resource.
This appears to reproduce the same "ERROR_ENCRYPTION_FAILED" relocation issue reported here, but importantly it is still present in 26.820.7780.0.
One additional
26.820.7780.0data point that may help narrow down the fatal bootstrap dependency:The Windows-native bundled CLI reproduces the same copy failure
The comments above already confirm the protected-resource failure for the bundled WSL/Linux
app\resources\codex.I independently tested the Windows-native binary as well:
On my
26.820.7780.0installation,codex.exeis also reported asEncrypted:Copying the native executable to a normal user-writable location fails the same way:
Result on zh-CN Windows:
So I can independently reproduce the protected/encrypted copy failure for both:
Disabling WSL alone was not sufficient
I explicitly switched Desktop to Windows-native mode:
but Desktop still exited during bootstrap with:
This is consistent with the newer
26.820behavior described above: the fatal startup path is no longer limited to provisioning the WSL CLI.Minimal startup bypass: external native CLI via
CODEX_CLI_PATHI then installed the official Windows CLI separately through npm:
Result:
The actual native executable is outside
WindowsApps:It executes normally.
I pointed
CODEX_CLI_PATHdirectly at that native executable:After restarting the Windows session, Codex Desktop was able to start again.
The potentially useful distinction here is that I did not reconstruct the complete per-user staging tree or recover all packaged runtime resources first. Providing a healthy Windows-native
codex.exeoutside the protected MSIX package was sufficient to get Desktop past the fatal bootstrap failure on this machine.I have not verified that this restores every other relocated runtime/helper (WSL helpers, Browser / Computer Use resources, etc.), so I would treat this specifically as a minimal Desktop-startup workaround, not as a complete recovery.
This may help identify which failed relocation is actually fatal during the early
26.820bootstrap path.A verified workaround without rolling back, modifying WindowsApps ACLs/ownership, or setting CODEX_CLI_PATH.
And stated the root cause
https://github.com/openai/codex/issues/40700#issuecomment-5419391502
Codex Desktop on Windows + WSL is currently broken for me after restart/update.
Environment:
Desktop fails at startup with:
Unable to locate the Codex CLI binaryLogs repeatedly show:
bundled_executable_relocation_failedduring
copy_file/copy_directory, withUNKNOWN (-4094)errors.cipher /cconfirms the bundledcodex.exeunder WindowsApps isApplication Protected.So this is not a broken WSL installation or Linux CLI. The Desktop bootstrap/runtime relocation path itself is failing.
Please fix the Windows + WSL cold-start/update path and add a regression test for this exact scenario. Users should not have to debug MSIX packaging internals just to restart an IDE.
And seriously: either make Windows + WSL stable, or give us a proper Linux desktop build. Right now both paths feel unnecessarily fragile.
[Windows][MSIX][26.820.60940] Bundled Codex executable relocation fails from WindowsApps on a secondary Appx volume, causing false “Unable to locate Codex CLI” startup error
This comment extends the issue from WSL relocation to the Windows-native bundled executable path in app version 26.820.60940.
Summary
The Codex Windows desktop app failed at startup with:
The bundled
codex.exewas not missing. It existed under the installed MSIX resources, had a valid OpenAI Authenticode signature, and was readable for inspection.The first recorded failure was instead a bundled-executable relocation error. The app attempted to copy the packaged executable from WindowsApps into
%LOCALAPPDATA%\OpenAI\Codex\bin\.staging-*; Node/Electron reported:syscall=copyfileerrno=-4094code=UNKNOWNsourceKind=windowsappsThe locator then returned no executable and converted this copy failure into the fatal “Unable to locate” message.
The package was installed on a secondary NTFS Appx volume, F:, with the nominal C: WindowsApps path implemented as a junction to F:. The packaged executable had the
Encryptedattribute.Installing the native Codex CLI, setting
CODEX_CLI_PATHdirectly to itscodex.exe, and rebooting allowed the desktop app to start. This workaround bypasses the failed bundled relocation; it does not repair it.Environment
10.0.2620026.820.60940OpenAI.Codex_26.820.7780.0_x64app\ChatGPT.execodex-cli 0.149.1C:\Program Files\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__...\F:\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__...\OpenAI.ChatGPT-Desktop 1.2026.190.0, was not the package producing this error. TheOpenAI.Codexpackage usesChatGPT.exeas its entry point, which likely explains the “ChatGPT failed to start” wording.Current post-workaround CLI state:
Get-Command codex -AllandGet-Command codex.exe -Allnow resolve only to that native executable. No npmcodex,codex.cmd,codex.ps1, or npm-managed@openai/codexpackage remains.The user- and process-level
CODEX_CLI_PATHnow point to the native executable; the machine-level variable is unset.Observed behavior
UNKNOWN/-4094.codex.exerelocation failures were recorded. The first successful session still logged bundled relocation errors, then spawned the explicitly configured native executable.UNKNOWNcopy failures were recorded for bundlednode,node_repl,corepack, andrg.exe, so the underlying relocation defect is broader than CLI discovery.Expected behavior
bin/codex, while the installed Windows implementation checks locations such asresources\codex.exe.Steps to reproduce
Status: evidence-backed reproduction candidate, not intentionally re-run after the workaround because doing so would require breaking a currently working installation.
OpenAI.Codexpackage to that volume.app\resources\codex.exehas theEncryptedattribute.CODEX_CLI_PATH.bundled_executable_relocation_failedevent while copying from WindowsApps to:C:\Users\<USERNAME>\AppData\Local\OpenAI\Codex\bin\.staging-*\codex.exeCODEX_CLI_PATH=C:\Users\<USERNAME>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exeAn npm-managed Codex shim existed earlier in the original user timeline, but current evidence does not show that npm coexistence is required to reproduce the initial bundled-relocation failure. It should be tested separately.
Diagnostic evidence
Bundled executable verification:
Condensed and redacted failure:
The next events report failure to connect to the app server, followed by:
Condensed successful session after the workaround:
Additional findings:
%LOCALAPPDATA%\OpenAI\Codex\bin.app.asarindicates that the native Windows relocation route usesfs.copyFileSyncand returns null after a copy exception.CopyFileExWwithCOPY_FILE_ALLOW_DECRYPTED_DESTINATION, but the native bundled-executable relocation path does not appear to use that helper.The official Codex installer had previously detected the npm-managed installation and warned:
That warning is relevant to wrapper coexistence, but it does not explain the earlier
copyfilefailure by itself.Workaround that fixed the issue
@openai/codexpackage.0.149.1.codex,where.exe codex, andGet-Command codex.exe -Allresolve to the native executable.CODEX_CLI_PATH=C:\Users\<USERNAME>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exeAfter reboot, the desktop application started successfully and initialized Codex CLI 0.149.1.
This is a confirmed bypass. Because bundled
codex.exe, Node runtime, andrg.exerelocation failures remain in the logs, it should not be treated as a full fix.Probable root cause
Confirmed application-level cause:
Probable Windows-level trigger:
Microsoft documents that
COPY_FILE_ALLOW_DECRYPTED_DESTINATIONpermits an encrypted source file to be copied even when the destination cannot be encrypted. MicrosoftCopyFileExdocumentation, handling encrypted files.This is also consistent with:
ERROR_ENCRYPTION_FAILED / Win32 6000while relocating encrypted MSIX resources in WSL mode.CopyFileWwithout the decrypted-destination flag, followed by mapping unrecognized Windows errors toUV_UNKNOWN;UV_UNKNOWNis-4094. libuv copy implementation, Windows error mapping,UV_UNKNOWN.The precise Electron/libuv build and underlying Win32 error were not captured in this machine’s application log. Therefore
ERROR_ENCRYPTION_FAILEDis a strong inference, not yet a confirmed local Win32 result.It is also not yet proven whether the secondary volume alone is sufficient, or whether the necessary combination is secondary volume + C: junction + encrypted package resource.
Alternative hypotheses
| Hypothesis | Assessment |
| --- | --- |
| npm shim/PATH conflict | Not the primary cause of the logged initial failure. The failure occurs during bundled-file copying before any CLI process is spawned. |
| Incorrect executable-resolution logic | Partially supported. The fallback/error logic is defective, and the message names an outdated or inaccurate
bin/codexlocation. Ambient PATH does not appear to be the default recovery path in the inspected build. || Bundled Codex missing | Refuted.
resources\codex.exeexists, is readable, hashes successfully, and has a valid OpenAI signature. || Incorrect bundled resource path | The app reached the correct packaged file; the failure was copying it, not finding it. |
| Environment inheritance | Reboot/new process was needed for the new user variable to be observed, which is normal Windows behavior. It does not explain the original bundled copy failure. |
| Stale CLI discovery/cache | No supporting evidence. No completed relocation cache exists, and reinstalling on the same Appx volume reproduced the failure. |
|
.cmd/.ps1spawn incompatibility | Plausible as a separate secondary defect. Existing issue #40752 reportsspawn EINVALwhenCODEX_CLI_PATHtargets a.cmdwrapper. It does not explain the default relocation failure. Node also documents special Windows handling requirements for.batand.cmdfiles. Node child-process documentation || ACL or antivirus block | Lower probability. The source could be inspected, the destination was writable, Appx ACL repair succeeded, and no Defender threat event matched the failure window. A filesystem filter-driver contribution cannot be completely excluded. |
Suggested engineering fix
COPY_FILE_ALLOW_DECRYPTED_DESTINATIONfor bundled Appx resources.rg.exerelocation.UNKNOWN/-4094.bin/codexwording with the actual attempted Windows paths.CODEX_CLI_PATHpoints to.cmdor.ps1, either resolve the underlying nativecodex.exeor reject the wrapper with an actionable error. Do not enable an unrestricted shell merely to make arbitrary wrappers executable.Regression-test recommendations
Test the following matrix:
CODEX_CLI_PATH.CODEX_CLI_PATHpointing to a valid native.exe..cmd,.ps1, missing file and non-executable file.ERROR_ENCRYPTION_FAILED, access denied, disk full and hash mismatch.Assertions should verify that:
Privacy/redaction notes
<USERNAME>.