最近使用chatgpt桌面端老是遇到点击软件之后之后没有chatgpt窗口的问题,但是在任务管理器里能看到chatgpt的进程。
已经碰到好几次了,尤其是软件自动版本更新之后比较容易出现。
发现,基本都是%LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node这个目录下面的runtime没复制完整造成的,一般会留下一个.staging-*目录,有时候里面有node.exe,但是缺node_repl.exe,然后软件就只有后台进程,前端死活出不来。
最简单的处理方法就是把Codex安装目录里的cua_node手动完整复制过去。
让AI给写了一个脚本
Get-Process ChatGPT,Codex -ErrorAction SilentlyContinue | Stop-Process -Force
$pkg = Get-AppxPackage OpenAI.Codex
$runtimeRoot = "$env:LOCALAPPDATA\OpenAI\Codex\runtimes\cua_node"
$staging = Get-ChildItem $runtimeRoot -Directory -Force -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like ".staging-*" } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($staging.Name -match '^\.staging-([0-9a-f]+)-') {
$hash = $Matches[1]
} else {
Write-Host "没找到 runtime hash"
return
}
$src = Join-Path $pkg.InstallLocation "app\resources\cua_node"
$dst = Join-Path $runtimeRoot $hash
New-Item -ItemType Directory -Force -Path $dst | Out-Null
& "$env:SystemRoot\System32\xcopy.exe" `
"$src\*" `
"$dst\" `
/E /I /H /Y /G /Q
Write-Host "node.exe:" (Test-Path "$dst\bin\node.exe")
Write-Host "node_repl.exe:" (Test-Path "$dst\bin\node_repl.exe")
Write-Host "manifest.json:" (Test-Path "$dst\manifest.json")
如果最后都提示:
True
True
True
再重新打开Codex就可以打开了,我每次都成功恢复了。
这个问题更新之后会再出现,不同版本的runtime hash会变。所以不要把hash写死,直接从.staging-*目录里取就行。