Troubleshooting ChatGPT (Codex) Desktop Edition Startup Failure: Root Cause and Fix Guide
If your ChatGPT (Codex) desktop app fails to start with a 'Unable to locate Codex CLI binary' error, this guide explains the EFS encryption root cause...
Many users of the ChatGPT (Codex) desktop application (distributed as an MSIX package via the Microsoft Store) have reported encountering a startup error: "ChatGPT failed to start. Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex." This issue stems from an unexpected interaction between file encryption and system capabilities.
The root cause lies in two key factors: First, the app's installation files (including codex.exe in the app\resources directory) are marked with EFS (Encrypting File System) encryption attributes. Second, the user's system does not support EFS encryption—verified by the [IO.FileInfo]::Encrypt() method throwing an "unsupported request" exception. When the app attempts to relocate the codex.exe binary from its installation directory to %LOCALAPPDATA%\OpenAI\Codex\bin\, the copy operation fails because it tries to preserve the encryption attribute, which the system cannot handle. This results in empty candidate paths for the binary, triggering the error.
To resolve this, the core strategy is to bypass EFS encryption by creating a non-encrypted copy of the necessary files and directing the app to use this copy via an environment variable:
- Stream-copy the binaries: Use a streaming method (combining [IO.File]::OpenRead and .CopyTo) to copy codex.exe, codex-code-mode-host.exe, codex-windows-sandbox-setup.exe, and codex-command-runner.exe to %LOCALAPPDATA%\OpenAI\Codex\bin\. This method removes the encryption attribute, producing plain files.
- Set the CODEX_CLI_PATH environment variable: Define a user-level variable pointing to the copied codex.exe. The app prioritizes this path over the relocation process, thus avoiding the failed copy step.
For convenience, a PowerShell script can be used to automate this process, especially after app updates:
# refresh-chatgpt-codex-bin.ps1
$ErrorActionPreference = 'Stop'
$pkg = Get-AppxPackage -Name 'OpenAI.Codex' | Sort-Object { [version] $_.Version } -Descending | Select-Object -First 1
if (-not $pkg) { throw 'OpenAI.Codex package not found' }
$res = Join-Path $pkg.InstallLocation 'app\resources'
$bin = Join-Path $env:LOCALAPPDATA 'OpenAI\Codex\bin'
New-Item -ItemType Directory -Force -Path $bin | Out-Null
$names = @('codex.exe', 'codex-code-mode-host.exe', 'codex-windows-sandbox-setup.exe', 'codex-command-runner.exe')
foreach ($n in $names) {
$s = Join-Path $res $n
$d = Join-Path $bin $n
if (-not (Test-Path $s)) { Write-Warning "Skipping (not found in package): $s"; continue }
$sourceStream = [IO.File]::OpenRead($s)
$destStream = [IO.File]::Create($d)
$sourceStream.CopyTo($destStream)
$sourceStream.Close()
$destStream.Close()
}
[Environment]::SetEnvironmentVariable('CODEX_CLI_PATH', (Join-Path $bin 'codex.exe'), 'User')
Write-Host "Refresh completed successfully. Restart ChatGPT Codex to apply changes."After applying these steps, the app should launch normally, with the codex.exe process running from the new directory and no more binary location errors.
Sources
- CSDN Blog: "Troubleshooting and Fixing ChatGPT (Codex) Desktop Edition Startup Failure" - https://blog.csdn.net/weixin_37647148/article/details/164109081