[Bug] Windows Desktop app fails to start after update to v26.820.60940 ("Unable to locate Codex CLI" & spawn EINVAL on .cmd wrapper)
What version of the Codex App are you using (From “About Codex” dialog)?
26.820.60940
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Windows 11 (x64)
What issue are you seeing?
After updating the Codex desktop app to version 26.820.60940, the application fails to launch on startup, reporting two sequential errors:
Initial launch failure:
Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex.
The desktop client fails to locate its bundled internal binary in the Electron resources/bin directory.
Secondary failure when specifying wrapper script:
When setting CODEX_CLI_PATH to the standard global npm command (codex.cmd), the app fails immediately with:
spawn EINVAL
This occurs because Electron's child_process.spawn() attempts to execute the .cmd wrapper directly without { shell: true }.
<img width="417" height="124" alt="Image" src="https://github.com/user-attachments/assets/b3fda2ea-4241-4f12-bcd2-ff053eb17f10" />
<img width="264" height="112" alt="Image" src="https://github.com/user-attachments/assets/2e5614e1-4cf3-405a-a949-36d9cd299d97" />
What steps can reproduce the bug?
Update Codex desktop to version 26.820.60940 on Windows 11.
Launch the application.
Observe the initial error: Unable to locate the Codex CLI binary.
Set the user environment variable CODEX_CLI_PATH to ...\nodejs\codex.cmd.
Relaunch the application.
Observe the secondary error: spawn EINVAL.
Workaround
Manually pointing CODEX_CLI_PATH directly to the underlying native executable binary bypasses both errors and successfully launches the application:
What is the expected behavior?
_No response_
Additional information
CODEX_CLI_PATH = <npm_root>\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe
Suggested Fixes
Ensure the Electron installer/updater bundles and extracts the native codex.exe binary into resources/bin/ by default.
If falling back to system PATH or CODEX_CLI_PATH on Windows, resolve .cmd/.bat wrappers appropriately or use { shell: true } when spawning batch files to prevent spawn EINVAL.
84 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Mine is loading but I cannot reply to any chats (new or existing). I can only start a chat, but cannot reply after the first message
I am experiencing the same issue on Windows.
Environment:
The issue started immediately after updating from 26.818.8289.0 to 26.820.7780.0.
Codex Desktop fails to start and reports:
"Unable to locate the Codex CLI binary......................."
I verified that the bundled Codex CLI exists:
C:\Program Files\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__2p2nqsd0c76g0\app\resources\codex.exe
The executable has a valid Authenticode signature.
However, executing the bundled CLI directly:
.\resources\codex.exe --version
results in:
"Access is denied."
Windows AppModel Runtime logs show that the Codex AppX process is successfully created (Event ID 201/211), but the AppX container is subsequently destroyed (Event ID 217).
The previous version 26.818.8289.0 worked correctly before the update.
This appears to be a Windows Desktop regression introduced by the 26.820.x update.
I have not modified WindowsApps ACLs or permissions.
Please let me know if there is a recommended workaround or a fixed/test build available.
metoo
艹,我也是
Same issue on Windows. Set environment variable CODEX_CLI_PATH bypasses the issue for me.
Same issue on Windows.
how to fix this?
Supplement / Solution Update:
Previously, setting the CODEX_CLI_PATH environment variable to point to an external native codex.exe allowed bypassing startup errors and launching the application, but this caused session lists and historical conversations to fail to load or open properly (due to IPC communication protocol or version incompatibility between the new desktop UI and the external CLI).
My current solution is to roll back (downgrade) directly to the previous desktop version (v26.818.8289.0).
Rollback Steps (PowerShell):
Download package: https://github.com/Wangnov/codex-app-mirror
Obtain the official MSIX installer for the previous version (e.g., ChatGPT-26.818.8289.0-x64.msix).
Remove any previously manually added CODEX_CLI_PATH environment variable to avoid conflicts with the older version:
PowerShell
[Environment]::SetEnvironmentVariable("CODEX_CLI_PATH", $null, "User")
Run PowerShell as administrator and execute the forced downgrade overwrite installation:
PowerShell installation command:
Add-AppxPackage -Path "installation package path\ChatGPT-26.818.8289.0-x64.msix" -ForceUpdateFromAnyVersion
For anyone facing the same issue: did you also install Codex on a non-C drive?
不是,要不等更新,要不老老实实回滚吧
确实不是在C盘,我装到D盘了
装c盘就可以正常使用了
确实,在设置-应用系统里移动到C盘后就可正常运行了。
有用!
Here's how I fixed it:
Wait for an update.
Can confirm the same issue on Windows after the update.
The native Codex CLI is installed correctly and works normally:
```text id="sh0vbb"
PS> codex --version
codex-cli 0.149.1
PS> where.exe codex
C:\Users\<user>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
As a workaround, explicitly setting
CODEX_CLI_PATHto the native executable fixes the startup issue for me:```powershell id="0rtxq3"
[Environment]::SetEnvironmentVariable(
"CODEX_CLI_PATH",
"$env:LOCALAPPDATA\Programs\OpenAI\Codex\bin\codex.exe",
"User"
)
Same issue happened just now on my Windows 11.
怎么解决这个问题,家人们
Me too
[Bug] ChatGPT Windows app v26.820.7780.0 cannot locate bundled Codex CLI after update
Microsoft Store package ID:9PLM9XGG6VKS
Package name:OpenAI.Codex
STOP DOING YOUR SHITTY APP WITH IA.
MORRONS
me too
Confirmed workaround on my Windows 11 machine
I had the same startup error:
My standalone CLI is on
D:. The key was to pointCODEX_CLI_PATHto the nativecodex.exe, not tocodex.cmd.After running this, I launched the ChatGPT desktop app immediately. It opened successfully; I did not need to reboot Windows.
This is only a workaround confirmed on my own PC. My standalone CLI is located at
D:\Codex\bin\codex.exe; I cannot determine from one machine whether the drive location is the root cause.References / credit
The workaround idea came from:
codex.execonfirmationThe result and the
D:\Codex\bin\codex.exepath above are from my own successful test.same
I’m seeing the same Windows startup failure on a newer Codex build:
Codex App: 26.820.7780.0
OS: Windows 11 x64
Environment: WSL enabled
Both bundled binaries are present:
...\app\resources\codex...\app\resources\codex.exeBoth have:
Attributes: Archive, EncryptedHowever, the relocated/staged binaries are missing:
%LOCALAPPDATA%\OpenAI\Codex\bin\codex.exe%USERPROFILE%\.codex\bin\wsl\codexManually copying the bundled
codexbinary also fails with:The specified file could not be encrypted.System.IO.IOExceptionThe app then fails at startup with:
Unable to locate the Codex CLI binary.A full Windows reboot did not resolve the issue.
This looks like a failure in the CLI relocation/staging step rather than a missing binary in the MSIX package. Importantly, it is still reproducible on 26.820.7780.0.
解决办法:卸载当前codex,改回默认的系统目录:C:\Program Files\WindowsApps\,重新在微软应用商店安装
如果是Electron 安装包没有把 codex.exe 放进 resources/bin/ 目录,
可以参考我这个方法:https://github.com/88lin/codex-desktop-windows-fix
I fixed this by moving ChatGPT app from D: to C: simply in setting>application>installed application, not sure work for everyone. win11
Before the update, it was installed on the C drive, but after the update, it moved to the D drive. You just need to move ChatGPT back to the C drive in the settings to fix it.
如果还打不开:有一个目前比较有效的临时解决办法
原理很简单:
现在 ChatGPT 在找:
codex.exe
但自己的安装包里没找到。
那我们自己装一份官方 Codex CLI,然后告诉 ChatGPT:
“Codex 在这里。”
OpenAI 现在有官方 Windows 安装脚本。
打开 PowerShell,运行:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
正常情况下 Codex 会安装到:
C:\Users\你的用户名\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
官方安装脚本本身也是把这个目录作为 Windows 默认安装位置。
安装完成之后,在 PowerShell 再运行:
[Environment]::SetEnvironmentVariable(
"CODEX_CLI_PATH",
"$env:LOCALAPPDATA\Programs\OpenAI\Codex\bin\codex.exe",
"User"
)
然后:
彻底退出 ChatGPT → 再重新打开。
注意一个很关键的小坑:一定要指向 codex.exe,不要指向 codex.cmd。
因为今天这个 Windows Bug 里,有人把 CODEX_CLI_PATH 指向 codex.cmd 后又碰到了 spawn EINVAL;直接指向真正的 codex.exe 则可以正常启动。
I encountered this issue on Codex Desktop “26.820.7780.0” after an update on Windows.
In my local case, the bundled CLI itself was not missing. “codex.exe” was present under the installed package path “app\resources”.
The actual failure occurred during bundled executable relocation. Codex Desktop attempted to copy the bundled CLI from the WindowsApps package into its local runtime directory:
The relocation failed with:
Similar relocation failures also occurred for bundled runtime files such as “cua_node”, so at least in my case, the final error message:
“Unable to locate the Codex CLI binary”
was a consequence of the relocation failure rather than the CLI binary actually being absent.
The important conflict I found locally was a mixed-drive MSIX/WindowsApps state: the Codex application was being loaded from “D:\WindowsApps”, while bundled resources were being resolved from “C:\Program Files\WindowsApps”.
After changing the Windows setting for the default location of new apps to the system drive “C:”, uninstalling Codex, and reinstalling it so the package was installed entirely on “C:”, Codex started normally again.
So, for my local case, the issue appears to have been related to WindowsApps/MSIX bundled executable relocation across mixed installation drives.
Confirmed solution for my environment:
No “CODEX_CLI_PATH” override was required.
This may not explain every occurrence of the same error, but it was the confirmed cause and fix on my machine.
Thanks! This worked for me on Windows 11. Moving the ChatGPT app from D: to C: fixed the issue immediately.
Confirmed a working workaround on Windows after hitting the same ChatGPT startup error (
Unable to locate the Codex CLI binary).In my case there were two layers to the problem:
where.exe codexreturned nothing).npm install -g @openai/codex, the wrapper was installed but running it failed with:Missing optional dependency @openai/codex-win32-x64.What worked:
After that:
The native Windows package was also present:
However, the ChatGPT Windows app still did not start by merely having
codex.cmdavailable. The final workaround was to locate the actual nativecodex.exeand setCODEX_CLI_PATHto that executable (not the.cmdwrapper):After fully quitting and restarting ChatGPT, the Windows app launched successfully.
So for this environment, pointing
CODEX_CLI_PATHdirectly to the nativecodex.exewas the key fix. Hopefully this helps confirm the issue/workaround for others.<img width="801" height="216" alt="Image" src="https://github.com/user-attachments/assets/76044677-8f74-4d66-8bc5-cccfc97c67c2" />
移动到C盘,正常启动了
2026年8月26日15:40,在windows11的设置里面,将codex从D盘移动到C盘,解决了同样的问题
At 15:40 on August 26, 2026, in the settings of Windows 11, moving Codex from drive D to drive C solved the same problem
<img width="1170" height="366" alt="Image" src="https://github.com/user-attachments/assets/39896452-29d6-4842-a8a7-848e0899a0ee" />
回滚到旧版本侧边栏聊天会话还在吗
我不太清楚,我没有使用回滚的办法,因为我的Cotex本身就是在d盘装的,我移动到c盘就好了,但是我估计回滚的话,只是把版本退回去,里边的数据应该都在的吧....
---Original---
From: @.*>
Date: Wed, Aug 26, 2026 16:09 PM
To: @.*>;
Cc: @.****@.**>;
Subject: Re: [openai/codex] [Bug] Windows Desktop app fails to start after update to v26.820.60940 ("Unable to locate Codex CLI" & spawn EINVAL on .cmd wrapper) (Issue #40752)
xufeng123-henan left a comment (openai/codex#40752)
回滚到旧版本侧边栏聊天会话还在吗
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>
Me too. What the hell!
那你的移动到C盘然后侧边栏会话记录还一样有保存吧
Additional evidence from the same Windows app release suggests that the initial “Unable to locate the Codex CLI” failure is separate from the later
.cmd/spawn EINVALbehavior described here.On app version 26.820.60940 (MSIX package 26.820.7780.0), the bundled native
app\resources\codex.exeexists and has a valid OpenAI signature. The first recorded failure occurs while relocating that executable from WindowsApps on a secondary Appx volume to%LOCALAPPDATA%\OpenAI\Codex\bin\.staging-*:operation=copy_filesyscall=copyfileerrno=-4094code=UNKNOWNsourceKind=windowsappsOnly after this relocation failure does the locator return no executable and surface the missing-CLI startup error.
Pointing
CODEX_CLI_PATHdirectly to the native Codex 0.149.1codex.exebypasses the bundled relocation path and allows the app to start. This is a workaround, not a repair of the underlying relocation failure.Full redacted diagnostic evidence: https://github.com/openai/codex/issues/38696#issuecomment-5422486768
我的已经在C盘了 现在咋办呢
I'm not working today until this gets fixed. Otherwise, I'll switch to Claude.
I don't want a bunch of hacky workarounds.
{ [Environment]::SetEnvironmentVariable(
"CODEX_CLI_PATH",
"D:\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__2p2nqsd0c76g0\app\resources\codex.exe",
"User")
}
[Environment]::GetEnvironmentVariable("CODEX_CLI_PATH", "User")
我也可以稳定复现,并且我的安装位置在非系统盘 F:。
难道一定要让我放到已经爆满的c盘吗!😭
Windows Desktop fails to locate Codex CLI after update when installed on non-system drive
Environment
F:\OpenAIC:\Users\Administrator\.codex\sessionsIssue
After a ChatGPT/Codex Desktop update, the application failed to start with:
However, the Codex CLI binary was present and executable at:
Running:
worked correctly.
Manually setting:
allowed the Desktop app to start.
Secondary issue
The bundled CLI at that location was an old version:
After the app started, recent conversations could not be restored and showed:
The affected sessions had been created by newer CLI versions:
I inspected the affected
.jsonlfiles and confirmed:So the session files themselves were valid.
Workaround
Installing the latest standalone Codex CLI and setting:
resolved both the application startup problem and the thread restore problem.
Suspected cause
The Windows Desktop updater appears to lose or incorrectly resolve the Codex CLI path when the application is installed on a non-system drive.
The fallback CLI located under the custom installation directory may also remain outdated, causing compatibility problems with sessions created by newer Desktop versions.
Expected behavior
After updating:
CODEX_CLI_PATH.有的
是的
Additional confirmed Windows workaround from another affected user:
Unable to locate the Codex CLI binary.Repairdid not help.%USERPROFILE%\.codex\.sandbox-bin\codex.exe.--versionsucceeded and reportedcodex-cli 0.148.0-alpha.9, confirming the CLI itself was healthy.CODEX_CLI_PATHto%USERPROFILE%\.codex\.sandbox-bin\codex.exerestored Codex Desktop startup successfully.This further supports a desktop startup/path-resolution regression rather than a corrupt CLI. The
.sandbox-bin\codex.exepath can also serve as a temporary recovery path when present.For installations located on a drive other than the C: drive, find the path to codex-code-mode-host.exe. In the same directory, there should also be a codex.exe file.
Set the path to codex.exe as the value of the CODEX_CLI_PATH environment variable, and the issue should be resolved.
<img width="836" height="208" alt="Image" src="https://github.com/user-attachments/assets/961f134d-275a-4d1a-a132-398c340749c0" />
Confirmed workaround on my Windows 11 x64 machine.
Environment:
I installed the CLI with:
The native executable was located at:
Equivalent generalized location:
Then I set
CODEX_CLI_PATHto that nativecodex.exe(notcodex.cmd):After fully restarting the Codex/ChatGPT desktop app (and Windows if necessary), the app started successfully for me.
I have only confirmed that this fixes the startup failure; I have not yet verified whether using the external CLI causes any session/history compatibility issues.
I can reproduce this on Windows: ChatGPT still fails to start with
Unable to locate the Codex CLI binaryeven after a full uninstall and clean reinstall. Could the OpenAI team please confirm whether a fixed Windows build is being prepared, and if possible provide an ETA (for example, whether the fix is expected within days)? Thanks.最终解决方案涉是啥
解决了?
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 升级后的 Windows 回归 Bug,不是你机器配置错了,也不是你“装了两个 Codex”导致的。
我刚查了今天的官方 Codex GitHub issue,和你的情况几乎一模一样:
CODEX_CLI_PATH指到codex.cmd又会报spawn EINVALCODEX_CLI_PATH指向 npm 包里面真正的codex.exe。([GitHub][1])所以你的故障链是:
为什么偏偏你会遇到?
你机器上的 CLI 是:
它是通过 npm 安装的。
npm 给你提供:
同时 package 内部又带了:
而新版 Desktop 在 Windows 上这一块的自动发现/打包路径出了问题。官方 issue 的 workaround 和我们给你设置的路径完全一致。([GitHub][1])
而且这不是孤立的 Windows 问题。最近 Codex Windows 的升级/打包路径确实连续出现过问题,例如 0.147.0 的 standalone auto-upgrade 就曾出现 launcher 和
codex-resources不匹配的问题。([GitHub][2])所以现在建议你什么都别折腾
保留现在的
CODEX_CLI_PATH。它相当于给 Desktop 加了一个明确的 fallback:
等后面 Desktop 修复了这个 bug,正常情况下也不会妨碍使用。
唯一需要注意的是:以后 npm 升级 Codex CLI 后,这个路径里面的 native binary 位置通常仍然在 package 内,但如果包结构发生变化,可能需要重新检查一次。
如果你想升级 Codex:
升级后检查:
**一句话:这次锅主要在新版 Codex Desktop 的 Windows CLI 自动发现/打包逻辑,不在你的 CLI 安装
<img width="1665" height="3057" alt="Image" src="https://github.com/user-attachments/assets/f5cacd85-367b-49d8-9408-74b017695716" />
绷不住了,没想到最后是这样解决的
Additional Windows workaround pitfall that may help others:
After the Desktop startup failure, setting
CODEX_CLI_PATHto a nativecodex.exedid make the app start, but I initially pointed it at an older cached binary under%LOCALAPPDATA%\OpenAI\Codex\bin\<hash>\codex.exe.That binary was
codex-cli 0.146.0-alpha.9.2. Desktop launched, but some existing paginated/reverted conversations then failed to resume with:The affected thread data itself was valid: the current reverted rollout had a distinct immutable rollout ID and a
history_basepointing to the original rollout. The failure disappeared immediately after changingCODEX_CLI_PATHto a current native CLI (0.149.1).This is consistent with the later fix in #38244 (
Resolve paginated thread history by rollout ID), which distinguishes the stable logical thread ID from the immutable rollout ID afterthread/revert.So for anyone using the
CODEX_CLI_PATHworkaround on Windows, I would strongly recommend verifying the binary version first:and avoiding stale cached binaries under
%LOCALAPPDATA%\OpenAI\Codex\bin\...unless their version is known to be current. A safer workaround is to pointCODEX_CLI_PATHdirectly to the nativecodex.exefrom a current CLI installation, not tocodex.cmdand not to an old cache.This may be worth mentioning in the startup error guidance, because an old native binary can appear to fix startup while silently introducing history-compatibility failures on newer paginated/reverted threads.
useful! Thanks
Same for me
I hit the same issue on Windows after updating Codex Desktop to 26.820.7780.0.
In my case, the root cause appears to be that Windows Store/AppX apps were installed on a non-system drive (D:).
Get-AppxDefaultVolumeshowed:The bundled
codex.exewas actually present, but the Codex logs showed that copying it from WindowsApps to LocalAppData failed:Immediately after that, Codex reported:
What fixed it for me:
Windows Settings → Apps → Installed apps → Codex → Move → C:
After moving Codex from D: to the system drive, it started normally again.
I did not need to install a separate Codex CLI, set
CODEX_CLI_PATH, modify WindowsApps permissions, or manually copy any files.So if anyone encounters this issue and
Get-AppxDefaultVolumepoints to a non-system drive, moving Codex back to C: may be worth trying first.Being lazy, I had codex cli fix it:
• Paste this into Codex CLI on the affected Windows machine:
Fix the Windows Codex desktop-app startup failure described in:
https://github.com/openai/codex/issues/40752
Symptoms may include:
spawn EINVALPlease diagnose and fix it safely:
codex --version, locate allcodexlaunchers, inspectnpm root --global, and check the current user-levelCODEX_CLI_PATH.codex.exeinside the globally installed@openai/codexnpm package. Search dynamically—do not hard-code my username, npm prefix,architecture, or drive.
CODEX_CLI_PATHatcodex.cmd,codex.ps1, or another script wrapper. It must point directly to a real nativecodex.exe.--version.CODEX_CLI_PATH, then persist the validated path at user scope using:[Environment]::SetEnvironmentVariable('CODEX_CLI_PATH', $nativeCodexPath, 'User')codex appand verify that the desktop app starts. Check the newest Codex desktop log for the previous missing-CLI orspawn EINVALerrors and confirmnormal startup activity.
CODEX_HOME, change npm’s prefix/cache, delete files, reinstall software, or terminate a working Codex/ChatGPT process unless necessary and explicitly approved.
This accommodates apps and repositories stored on D: or another native Windows drive, which the official Windows app documentation
(https://learn.chatgpt.com/docs/windows/windows-app) supports.
<img width="555" height="166" alt="Image" src="https://github.com/user-attachments/assets/1cf62ea7-76f4-451e-b044-3e81625f6843" />
Same here
For anyone still blocked on Windows after the 26.820.x update: I hit a very similar failure chain and got the Desktop working again without changing ACLs under
C:\Program Files\WindowsApps.What worked on the affected machine:
CODEX_CLI_PATHatcodex.cmd. Locate the native Windows binary inside the npm package and verify it first:Then run the newest candidate with
--version. On the recovered machine the working binary wascodex-cli 0.149.1under a path ending in:CODEX_CLI_PATHto that native exe, then fully restart Desktop/Windows:Two extra gotchas I saw on the same machine:
codex mcp listfails before listing anything, check the active config. One machine hadservice_tier = "priority", while the current parser expectedfastorflex; backing up the config and changing that value tofastfixed config loading.Also check whether a normal PowerShell startup is throwing Conda/Python profile errors while
powershell -NoProfileworks — that can break Desktop initialization independently of the CLI issue.This is a workaround/diagnostic path, not an official fix. If anyone is still stuck after the native-CLI step, reply with just: Windows build, Desktop version,
where codex,codex --version, and the exact error text. Please redact tokens/API keys.Thanks for the bug report. We understand the problem and are working on expediting a fix.
This solved my problem:
Windows Settings → Apps → Installed apps → Codex → Move → C (or D, depending on your directory):
After moving Codex from D: to the system drive, it started working normally again.
问题在于:你这个 Windows 桌面版当前有一个已知 bug,它不认 npm 生成的 codex.cmd 包装器,而是想直接拿到真正的 codex.exe。 昨天就有人报告了和你几乎一模一样的问题:Windows 11、桌面端启动提示 Unable to locate the Codex CLI binary;把 CODEX_CLI_PATH 指向 .cmd 还会触发 spawn EINVAL。目前的 workaround 是直接把它指向 npm 包内部真正的 codex.exe。
你直接在 PowerShell 执行下面这个,先找到真正的 exe:
Get-ChildItem "$env:APPDATA\npm\node_modules\@openai\codex" -Recurse -Filter codex.exe | Select-Object -ExpandProperty FullName
正常应该出来一个类似:
C:\Users\<用户名>\AppData\Roaming\npm\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe
这正是目前报告里有效的 native binary 路径。
然后把它保存成环境变量。最省事可以直接:
$codexExe = Get-ChildItem "$env:APPDATA\npm\node_modules\@openai\codex" -Recurse -Filter codex.exe |
Select-Object -First 1 -ExpandProperty FullName
[Environment]::SetEnvironmentVariable(
"CODEX_CLI_PATH",
$codexExe,
"User"
)
$codexExe
最后一行应该打印那个完整的 ...\codex.exe 路径。
再验证:
[Environment]::GetEnvironmentVariable("CODEX_CLI_PATH", "User")
然后完全退出桌面版 ChatGPT/Codex,注意不是只关窗口,最好任务管理器里确认 ChatGPT / Codex 进程都没了,再重新启动。
回滚已解决这个版本的问题:
仓库:https://github.com/Wangnov/codex-app-mirror/releases/tag/codex-app-26.818.61809
参考回滚命令:Add-AppxPackage -Path "F:\Downloads\OpenAI.Codex_26.818.8289.0_x64__2p2nqsd0c76g0.Msix" -ForceUpdateFromAnyVersion
Confirmed workaround on Windows 11: rolling the Codex desktop app back to the previous 26.818.61809 release resolves the startup failure introduced by 26.820.60940.
Third-party mirror used for the rollback package:
https://github.com/Wangnov/codex-app-mirror/releases/tag/codex-app-26.818.61809
Example PowerShell rollback command:
After installing the older MSIX with
-ForceUpdateFromAnyVersion, the desktop app starts normally again. This suggests the regression is specific to the newer Windows desktop build/update rather than the local npm Codex installation.Note: the linked mirror is an unofficial third-party repository, so users should verify the package/source before installing.
请问这个是否会影响下一步更新
how did you fix it?
and it can update the newest version in the future?
不影响桌面端正常更新。这个方法只是额外设置 CODEX_CLI_PATH,不会修改或替换 ChatGPT/Codex 桌面端文件。不过这个环境变量会在更新后继续存在;如果后续官方修复了该问题,可以删除它。若 Codex CLI 更新后内部 exe 路径发生变化,则需要重新设置一次。
Settings → Apps → Installed apps → ChatGPT → Move → C:
Why hasn't the official update this bug yet? I don't want to manually point it.
This worked. Thanks!
Complete diagnostic write-up:
spawn EINVALon.cmdwas layer 2 of 3 stacked root causes — with a runtime forensics method to see exactly what the app spawnsAfter fixing my machine (Win11 Home, package
OpenAI.Codex_26.820.7780.0, installed on D: by a third-party "app relocation" tool), I found the failure was three stacked causes, each one hiding the next. Posting here since layers 1 & 3 are what people hit right after applying theCODEX_CLI_PATHworkaround.Layer 2 (this issue): why
CODEX_CLI_PATH→codex.cmdthrows synchronouslyNode ≥ 18.20 / 20.12 / 22 refuses to
spawn()a.cmd/.batwithoutshell: true— this is the CVE-2024-27980 (BatBadBut) mitigation, and it throws synchronously fromChildProcess.spawnbefore ever reachingCreateProcess(which matches the stack trace in the logs). Minimal repro:How to see exactly what the app is spawning (beats static analysis of the asar): launch the exe directly with a
--requirehook — MSIX apps launched viashell:AppsFolderare spawned by the system and don't inherit your session env, but launching the exe path directly does:The hook wraps
child_process.spawnand logs cmd/args/opts. It captured:Fix that worked here: delete the env var entirely instead of pointing it at an
.exe:The desktop app then falls back to its bundled staged exe under
%LOCALAPPDATA%\OpenAI\Codex\bin\<hash>\codex.exe, which spawns cleanly (same major version as the app — avoids the version-mismatch symptom reported above where pointing at an external/older CLI breaks session history).Two caveats from my debugging session:
Remove-Item Env:\CODEX_CLI_PATHin the launching command.Layer 1 (covered by #40843 / #38696): EFS-encrypted package directory
If
%LOCALAPPDATA%\OpenAI\Codex\bin\<hash>\contains 0-byte or missing files and the logs showcopyfile ... UNKNOWN -4094: the package directory carries the EFSEncryptedattribute (relocation tool wrote it encrypted), and Win11 Home can neither encrypt new files nor decrypt existing ones (cipher /eand/dboth fail with "not supported"), so relocation can never succeed.UNKNOWN -4094is Node's unmapped representation of Win32 error 6000ERROR_ENCRYPTION_FAILED— P/InvokeCopyFileW+GetLastWin32Errorshows the real code immediately.Reinstall is the only fix on Home, and
Set-AppxDefaultVolume -Volume C:\must be run first, or the fresh package lands on the encrypted volume again.Layer 3:
state_5.sqlitefailing to initializeAfter layers 1–2 were fixed, app-server spawned fine but exited immediately with:
Bisection (move all six
*.sqliteout of~/.codex, put them back one at a time) isolated it tostate_5.sqlite:integrity_check= ok, all 50_sqlx_migrationsrowssuccess=1, opens read-only fine — but both 0.150.0-alpha.8 (bundled) and 0.149.1 (npm) fail to initialize the state runtime on it. Deleting it and letting the app rebuild fixed startup; session transcripts in~/.codex/sessions/*.jsonlare unaffected (lost 30 rows of thread metadata).This error message currently gives no hint of which DB or which step failed — that turned a 5-minute check into a multi-hour hunt (see also #30105 / #39015 for the same pain on other DBs). Improving this on the Rust side would be a very welcome fix.
I encountered the same issue on Windows 11.
In my case, the Codex CLI itself was installed and working, but the ChatGPT Windows app could not locate the native
codex.exebinary.What worked for me was setting
CODEX_CLI_PATHdirectly to the native executable inside the globally installed@openai/codexpackage, rather than pointing it to the npm wrapper (codex.cmd).I documented the troubleshooting process and the workaround here:
https://github.com/2026-l/chatgpt-windows-codex-cli-fix
This is only a community workaround based on my own environment, not an official fix. Hopefully this information can help with diagnosing the underlying issue.
I’m seeing the same issue on Windows.
The Codex desktop app fails to start with:
Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex.I confirmed that
codex.exedoes exist inside the installed app package, but when I try to execute it manually, Windows returns:Access is denied.So in my case, this does not appear to be simply a missing CLI binary — the binary is present, but the app / Windows is unable to execute it from the WindowsApps package location.
What I have tried so far:
codex.exeexists in the packagecodex.exemanuallyAccess is deniedEnvironment:
26.820.7780.0Unable to locate the Codex CLI binaryAccess is deniedThis appears to match the behavior described in this issue.
If useful, I can provide additional logs, package paths, or diagnostics.
Adding another reproducible Windows report:
Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex.Check for Updatesreports that ChatGPT is already up to date.CODEX_CLI_PATHworkaround has been applied.This appears to be a regression affecting a clean/reinstalled Windows setup as well, not just a damaged local installation. The app is currently unusable on this machine until a fixed build is released.
I encountered the same issue on Windows 10 today. The app was working fine before the last shutdown, and I didn't initiate any updates.
OS Version: Win 10 PRO 22H2
ChatGPT Desktop App Version: 26.820.7780.0
ERROR:
ChatGPT failed to start:Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex.
Here is the log:
codex-desktop-b810af78-b248-4eb3-9218-3c7bbec26a98-10676-t0-i1-073711-0.log
It worked for me on Windows 10 by simply following the steps. I didn’t have Codex CLI installed, so I installed it, set the environment variables, and the application started working when I launched it.
Thank you for your help.
我在微软商店下载的,他自动默认安装到c盘,我不会改
Checking for update and installing the newest update fixed this for me.