Codex 桌面版打不开:Windows 故障解决方案
适用现象:Microsoft Store 安装的 Codex/ChatGPT 桌面版更新后打不开、启动后立即退出、提示找不到 Codex CLI、Browser/Computer Use 不可用,或本地任务提示执行环境启动/握手失败。
整理日期:2026-09-11
结论先说
这不是一个单一故障,最常见的是 Windows Store/MSIX 包内的受保护文件无法被 Codex 复制到用户缓存目录。典型日志包括:
Unable to locate the Codex CLI binary
bundled_executable_relocation_failed
errno=-4094 / errorCode=UNKNOWN / syscall=copyfile
The specified file could not be encrypted
Windows Computer Use helper paths are unavailable
local execution environment failed to start优先按下面顺序处理:
- 彻底退出 Codex,先备份
%USERPROFILE%\.codex中的重要数据。 - 若日志有
-4094、copyfile、WindowsApps或Unable to locate the Codex CLI binary,执行“受保护资源流式复制”方案。 - 若只是 Browser/Computer Use 不可用,先重命名插件缓存,让 Codex 自动重建。
- 若是启动时
chrome.dll崩溃或白屏,尝试禁用 GPU 启动,然后立即更新应用。 - 若错误明确提到
approval_policy = "untrusted",只删除这一项,不要清空整个.codex。
不要一开始就删除整个 .codex:其中可能包含登录信息、配置、会话和项目历史。
一、知乎文章方案的整理与改进
来源:Codex 桌面版打不开?手动修复完整教程(不用现成脚本)
知乎文章给出的核心方法是:计算当前商店包资源的版本哈希,把 codex.exe、rg.exe、cua_node 等资源以“普通字节流”复制到用户缓存目录,绕过 WindowsApps/Application Protected 文件的普通复制失败。
这条路线与 OpenAI Codex 官方 GitHub 中的 Windows issue 相互印证:官方 issue 记录了 WindowsApps 中的资源带有 Encrypted、Application Protected 属性,Node.js copyfile、Copy-Item 和 robocopy 都可能返回 -4094 或“指定的文件无法加密”。
1. 先退出应用并备份
任务管理器中结束 Codex/ChatGPT 及其子进程。PowerShell 中可执行:
Get-Process | Where-Object {
$_.ProcessName -match 'Codex|ChatGPT|extension-host|node_repl'
} | Stop-Process -Force -ErrorAction SilentlyContinue备份配置和会话目录:
$codexHome = Join-Path $env:USERPROFILE '.codex'
$backupRoot = Join-Path $env:USERPROFILE ('.codex-backup-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
New-Item -ItemType Directory -Path $backupRoot -Force | Out-Null
foreach ($name in @('config.toml', 'auth.json', 'sessions', 'archived_sessions', 'state_5.sqlite')) {
$source = Join-Path $codexHome $name
if (Test-Path -LiteralPath $source) {
Copy-Item -LiteralPath $source -Destination $backupRoot -Recurse -Force
}
}
Write-Host "备份完成:$backupRoot"2. 计算当前版本的缓存目录名
在同一个 PowerShell 窗口中执行,不要中途换窗口:
$pkg = Get-AppxPackage OpenAI.Codex |
Sort-Object Version -Descending |
Select-Object -First 1
if (-not $pkg) { throw '找不到 OpenAI.Codex 商店包,请确认已安装 Codex/ChatGPT 桌面版。' }
$res = Join-Path $pkg.InstallLocation 'app\resources'
$local = Join-Path $env:LOCALAPPDATA 'OpenAI\Codex'
function Get-BundleId([string]$root, [string[]]$names) {
$sb = New-Object System.Text.StringBuilder
foreach ($n in $names) {
$path = Join-Path $root ($n -replace '/', '\\')
if (-not (Test-Path -LiteralPath $path)) {
throw "资源不存在:$path"
}
[void]$sb.Append($n)
[void]$sb.Append([char]0)
[void]$sb.Append((Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLower())
[void]$sb.Append([char]0)
}
$sha = [System.Security.Cryptography.SHA256]::Create()
try {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($sb.ToString())
return ([BitConverter]::ToString($sha.ComputeHash($bytes))).Replace('-', '').ToLower().Substring(0, 16)
}
finally { $sha.Dispose() }
}
$cliId = Get-BundleId $res @(
'codex.exe',
'codex-code-mode-host.exe',
'codex-windows-sandbox-setup.exe',
'codex-command-runner.exe'
)
$rgId = Get-BundleId $res @('rg.exe')
$cuaId = Get-BundleId (Join-Path $res 'cua_node') @(
'manifest.json',
'bin/node.exe',
'bin/node_repl.exe'
)
"Package=$($pkg.Version)"
"Resources=$res"
"CLI=$cliId"
"RG=$rgId"
"CUA=$cuaId"3. 用字节流复制 CLI 和 rg
不要使用资源管理器、Copy-Item 或普通 robocopy 直接复制 WindowsApps 内的源文件。使用下面的流式复制函数:
function Copy-Plain([string]$src, [string]$dst) {
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $dst) | Out-Null
$inputStream = [System.IO.File]::OpenRead($src)
$outputStream = [System.IO.File]::Create($dst)
try { $inputStream.CopyTo($outputStream) }
finally {
$outputStream.Dispose()
$inputStream.Dispose()
}
}
$cliDst = Join-Path $local "bin\$cliId"
foreach ($file in @(
'codex.exe',
'codex-code-mode-host.exe',
'codex-windows-sandbox-setup.exe',
'codex-command-runner.exe'
)) {
Copy-Plain (Join-Path $res $file) (Join-Path $cliDst $file)
}
Copy-Plain (Join-Path $res 'rg.exe') (Join-Path $local "bin\$rgId\rg.exe")先验证 CLI:
& (Join-Path $cliDst 'codex.exe') --version能正常打印版本号后,尝试从开始菜单打开 Codex。若应用已经恢复,不要继续执行后面的步骤。
4. 只有 CUA 目录缺失时,再复制 cua_node
查看:
Get-ChildItem (Join-Path $local 'runtimes\cua_node') -Force -ErrorAction SilentlyContinue |
Select-Object Name, Attributes如果已经存在 $cuaId 对应的目录,跳过本节;如果只有 .staging-*,再执行:
function Copy-DirPlain([string]$src, [string]$dst) {
Get-ChildItem -LiteralPath $src -Recurse -Force | ForEach-Object {
$relative = $_.FullName.Substring($src.Length).TrimStart('\\')
$target = Join-Path $dst $relative
if ($_.PSIsContainer) {
New-Item -ItemType Directory -Force -Path $target | Out-Null
}
else {
Copy-Plain $_.FullName $target
}
}
}
$cuaDst = Join-Path $local "runtimes\cua_node\$cuaId"
Copy-DirPlain (Join-Path $res 'cua_node') $cuaDst确认 node.exe、node_repl.exe 和 manifest.json 存在后再启动应用:
Get-Item (Join-Path $cuaDst 'manifest.json'),
(Join-Path $cuaDst 'bin\node.exe'),
(Join-Path $cuaDst 'bin\node_repl.exe')5. 说明:为什么普通复制会失败
Microsoft 的 MSIX 说明指出,商店应用文件位于受保护的 WindowsApps 目录;Codex 的官方 issue 进一步记录了某些包文件显示为 Encrypted 和 Application Protected。源文件通常可以读取、哈希也能成功,但复制到普通用户目录时,Windows 仍可能尝试按 EFS 属性处理目标文件,从而失败。
因此这里的“流式复制”只是生成不带该保护属性的普通副本,不是关闭 Windows 安全机制,也不是修改 WindowsApps 的权限。不要取得 WindowsApps 所有权或批量修改其 ACL,这可能导致商店应用损坏。
二、Browser / Computer Use 不可用:先重建插件缓存
适用症状
- 设置中 Browser 显示 unavailable;
- Computer Use 显示 “Computer Use plugins unavailable”;
- Chrome 扩展配置消失;
- 更新后几小时前还正常,重启后失效;
.codex\.tmp\bundled-marketplaces\openai-bundled目录只有部分文件,缺少\.agents\plugins\marketplace.json;- 日志出现
missing-helper-path、EBUSY、EPERM或bundled_plugins_marketplace_resolve_failed。
推荐做法:重命名而不是删除
Reddit 高反馈帖子中有多名用户确认,结束 Codex 和 extension-host.exe 后,重建 browser/chrome 缓存可以立即恢复。另一篇帖子公开页面可见 29 分、100% upvote ratio,并有用户反馈该方法解决了 Browser/Computer Use 不可用。
先退出应用,再执行:
Get-Process | Where-Object {
$_.ProcessName -match 'Codex|ChatGPT|extension-host|node_repl'
} | Stop-Process -Force -ErrorAction SilentlyContinue
$root = Join-Path $env:USERPROFILE '.codex'
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$paths = @(
(Join-Path $root 'plugins\cache\openai-bundled'),
(Join-Path $root '.tmp\bundled-marketplaces\openai-bundled')
)
foreach ($path in $paths) {
if (Test-Path -LiteralPath $path) {
Rename-Item -LiteralPath $path -NewName ((Split-Path $path -Leaf) + ".bak-$stamp")
}
}重新打开 Codex,等待 60–90 秒,让它重新生成插件缓存。确认恢复后,可以手动删除旧的 .bak-* 目录;建议先保留几天,不要急于删除。
如果目录被锁定,重启 Windows,启动 Codex 前再执行:
$root = Join-Path $env:USERPROFILE '.codex'
$parent = Join-Path $root '.tmp\bundled-marketplaces'
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
Get-ChildItem -LiteralPath $parent -Directory -Filter 'openai-bundled*' -ErrorAction SilentlyContinue |
ForEach-Object {
Rename-Item -LiteralPath $_.FullName -NewName ($_.Name + ".bak-$stamp") -Force
}不要随意改这些配置
如果使用全局 npm CLI 操作插件,而桌面版又在启动时管理同一个 %USERPROFILE%\.codex\config.toml,两个版本可能互相覆盖 openai-bundled、Browser、Chrome、Computer Use 和 node_repl 配置。官方 issue #26366 已记录这种来源冲突。
排障期间不要直接用全局 codex plugin marketplace add/remove 改桌面版的内置 marketplace。若必须改 config.toml,先备份,并只修改明确对应故障的配置项。
三、启动后立即崩溃、白屏或卡 Logo:GPU 分支
适用症状
Crashpad/WinDbg 显示类似:
PROCESS_NAME: Codex.exe
EXCEPTION_CODE: c0000005
MODULE_NAME: chrome
IMAGE_NAME: chrome.dllReddit 的解决反馈显示,临时禁用 GPU 启动后进入应用,再在应用内完成更新,随后开始菜单正常启动恢复。这个方法只针对 Electron/Chromium/GPU 崩溃,不适用于 -4094 文件复制错误。
$env:ELECTRON_DISABLE_GPU = '1'
$pkg = Get-AppxPackage OpenAI.Codex |
Sort-Object Version -Descending |
Select-Object -First 1
$app = Join-Path $pkg.InstallLocation 'app'
$exe = Join-Path $app 'Codex.exe'
Start-Process -FilePath $exe `
-WorkingDirectory $app `
-ArgumentList '--disable-gpu', '--disable-gpu-compositing'一旦进入应用,立即检查并安装可用更新,再关闭应用并从开始菜单正常启动。不要把 ELECTRON_DISABLE_GPU 永久写入系统环境变量,除非确认 GPU 驱动确实导致问题。
四、WSL 相关启动失败
先判断是否真的在使用 WSL
如果错误中有:
Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND说明 WSL 功能可能已开启,但没有默认 Linux 发行版。官方 Microsoft 文档推荐使用管理员 PowerShell 执行:
wsl --list --online
wsl --install -d Ubuntu按提示重启,并首次启动 Ubuntu 完成用户名和密码设置。验证:
wsl -l -v如果 Codex 实际使用的是 Windows native agent,则不必为了普通 PowerShell 工作流安装 WSL;只有配置为 WSL agent、或日志明确指向 WSL 缺少发行版时才处理这一分支。官方 Windows 文档说明,Codex 可以在 Windows native 和 WSL2 之间切换,切换后需要重启应用。
五、配置策略导致 Codex 根本无法启动
OpenAI 官方帮助文档目前明确说明:Codex CLI 0.149.0 及以上、桌面版 26.818.31338 及以上不再支持:
approval_policy = "untrusted"如果启动错误明确提到这项,执行:
$cfg = Join-Path $env:USERPROFILE '.codex\config.toml'
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
Copy-Item -LiteralPath $cfg -Destination "$cfg.bak-$stamp" -Force
$text = Get-Content -LiteralPath $cfg -Raw
$text = [regex]::Replace(
$text,
'(?m)^\s*approval_policy\s*=\s*["'']untrusted["'']\s*\r?\n?',
''
)
Set-Content -LiteralPath $cfg -Value $text -Encoding utf8需要保守权限时,官方建议使用:
sandbox_mode = "read-only"
approval_policy = "on-request"注意:项目级 trust_level = "untrusted" 与 approval_policy = "untrusted" 不是同一项,不要误删前者。
六、登录、CLI 和本地缓存异常
只清 auth.json
如果表现是反复登录、登录后马上退出、其他功能正常,OpenAI Developer Community 的高互动讨论中有用户确认:退出应用、移走 auth.json 后重新登录可以恢复,而且比清空整个 .codex 更能保留历史。
Get-Process | Where-Object { $_.ProcessName -match 'Codex|ChatGPT' } |
Stop-Process -Force -ErrorAction SilentlyContinue
$auth = Join-Path $env:USERPROFILE '.codex\auth.json'
if (Test-Path -LiteralPath $auth) {
Rename-Item -LiteralPath $auth -NewName ('auth.json.bak-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
}重新打开后按提示登录。不要把登录凭据或 auth.json 上传到论坛、网盘或 issue。
全局 CLI 与桌面版版本不一致
如果桌面版和 CLI 分别使用不同版本,先检查:
codex --version
Get-ChildItem (Join-Path $env:LOCALAPPDATA 'OpenAI\Codex\bin') -Recurse -Filter 'codex.exe' -ErrorAction SilentlyContinue |
Select-Object FullName, Length, LastWriteTimeOpenAI 官方文档也提醒,桌面版和 CLI 可能包含不同 Codex 版本。不要把“全局 CLI 能运行”当成“桌面版内部运行时正常”的证明。
七、Windows 设置中的 Repair/Reset 什么时候用
Windows 官方建议路径:
设置 → 应用 → 已安装的应用 → ChatGPT/Codex → 高级选项 → 修复
如果修复无效,再考虑 重置。但 Reset 可能清除应用本地数据,先备份 .codex。对于本篇主线的 WindowsApps 受保护文件复制错误,官方 Codex issue 中已有报告表明 Repair 和重新安装可能都无效,因为用户目录中的缓存或配置会保留,或者应用每次启动仍会重复触发同一复制失败。
因此推荐:
- 普通应用状态损坏:先 Repair;
- 只是插件缓存损坏:重命名
plugins\cache\openai-bundled和.tmp\bundled-marketplaces\openai-bundled; - 明确
-4094/copyfile:优先执行流式复制; - 需要 Reset/重装:先备份会话,再操作。
八、最后的验证清单
按故障类型验证,不要只看窗口是否出现:
# 1. CLI 能否运行
$cli = Get-ChildItem (Join-Path $env:LOCALAPPDATA 'OpenAI\Codex\bin') -Recurse -Filter 'codex.exe' -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($cli) { & $cli.FullName --version }
# 2. WSL 是否有默认发行版
wsl -l -v
# 3. 配置中是否仍有已废弃策略
$cfg = Join-Path $env:USERPROFILE '.codex\config.toml'
Select-String -LiteralPath $cfg -Pattern 'approval_policy|sandbox_mode|trust_level' -ErrorAction SilentlyContinue
# 4. 插件缓存是否已生成
Get-ChildItem (Join-Path $env:USERPROFILE '.codex\plugins\cache\openai-bundled') -Directory -ErrorAction SilentlyContinue |
Select-Object Name应用恢复后,至少完成以下测试:
- 新建一个本地任务并执行
Get-Location; - 打开 Browser(如果使用该功能);
- Computer Use 能否列出窗口/应用;
- 重启一次 Codex 后是否仍正常;
- 商店更新后,CLI/Browser/Computer Use 的版本是否一致。
九、哪些方法不建议直接采用
1. 直接删除整个 .codex
这会丢失或破坏登录状态、配置、插件状态和本地会话索引。除非已经完整备份并确认可以接受重建,否则只处理对应的缓存目录。
2. 修改 WindowsApps 所有权和 ACL
这可能破坏 MSIX 签名校验和商店更新机制,也不能从根本上修复 Codex 的复制逻辑。
3. 长期把 openai-bundled 指向自建固定目录
官方 issue #26501 记录了固定 marketplace、手工安装插件只能暂时恢复,更新或重启后仍可能被桌面版重新同步覆盖。可以用于临时诊断,不建议作为长期方案。
4. 未经症状匹配就安装 WSL、改沙箱或禁用 GPU
这些操作只对相应日志有效。先根据错误文本选择分支,避免把多个不同问题混在一起。
十、资料筛选说明
本整理优先保留:
- 官方 OpenAI Help/ChatGPT Learn 文档;
- OpenAI Codex GitHub 官方 issue,尤其是有复现步骤、日志和文件属性证据的报告;
- Reddit/OpenAI Developer Community 中有明确“已解决/works/fixed”反馈的高互动讨论;
- 用户指定的知乎原文。
很多网站不公开真实访问量,因此“高访问量”无法统一精确核验;本文用公开可观察的互动信号(帖子评分、upvote ratio、评论数量和多名用户的成功反馈)作筛选。没有公开访问/评论证据、仅凭作者推测的文章不作为主方案。知乎原文因是用户指定来源,即使页面的实时阅读/评论数据无法稳定抓取,也保留并与官方 issue 交叉验证。
参考资料
用户指定来源
官方 OpenAI / Codex
- OpenAI Help:Using Codex with your ChatGPT plan —— Windows 工具、
codex doctor、approval_policy = "untrusted"启动失败说明。 - ChatGPT Learn:ChatGPT desktop app for Windows —— Windows native/WSL2、PowerShell、桌面版与 CLI 版本差异。
- OpenAI Codex GitHub issue #40700 —— 26.820 更新后
codex.exe从 WindowsApps relocation 失败,错误-4094。 - OpenAI Codex GitHub issue #34764 —— Application Protected 的
cua_node、插件和 Computer Use helper 复制失败。 - OpenAI Codex GitHub issue #25220 —— WindowsApps 受保护文件导致 bundled plugins 无法复制。
- OpenAI Codex GitHub issue #26501 —— 更新后 bundled marketplace 不完整,Browser/Computer Use unavailable。
- OpenAI Codex GitHub issue #26366 —— 全局 CLI 与桌面版同时修改共享配置造成 marketplace 来源冲突。
社区成功反馈
- Reddit:Windows native browser use fix —— 复制用户缓存中的 helper 后 Browser Use 恢复,评论有“fixed problem”“Browser never worked…works now”等确认。
- Reddit:Possible fix/workaround for Windows Codex Browser/Computer Use —— 重命名插件缓存并重建,公开页面显示 29 分、100% upvote ratio;评论区有多条“worked perfectly/works like a charm”反馈。
- Reddit:Codex update 5/29—won’t open ——
chrome.dll崩溃时禁用 GPU 启动并完成更新,作者反馈之后开始菜单正常启动。 - OpenAI Developer Community:Bug: Codex Desktop App Doesn’t Load, Stuck on Logo Screen —— 评论中有清理
auth.json、更新 CLI 后重新登录等成功反馈。