Skip to content

I encountered the same issue: Windows Codex Desktop fails to start with "Unable to locate the Codex CLI binary" #40853

Open

Description

@xiaoxinquan

What version of the Codex App are you using (From “About Codex” dialog)?

Windows Codex Desktop fails to start: "Unable to locate the Codex CLI binary" even though codex.exe is installed and accessible

What subscription do you have?

After launching the Codex Desktop application, it immediately fails with: "ChatGPT failed to start. Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex."

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Title:

I encountered the same issue: Windows Codex Desktop fails to start with "Unable to locate the Codex CLI binary"

Description:

I encountered the same issue on Windows and would like to provide additional diagnostic information and a workaround.

After launching Codex Desktop, the application fails immediately with:

"ChatGPT failed to start.

Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex."

Environment:

  • OS: Windows 11 x64
  • Application package: OpenAI.Codex
  • Version: 26.820.7780.0

Investigation:

I verified that the Codex CLI installation itself is working correctly.

Standalone Codex CLI path:

C:\Users\lenovo\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe

Running:

codex --version

returns:

codex-cli 0.149.1

I configured the environment variable:

CODEX_CLI_PATH

with:

C:\Users\lenovo\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe

The environment variable is correctly stored and the executable can be launched successfully.

Additional findings:

The installed Windows package contains:

app\resources\codex.exe

but does not contain:

app\resources\bin\codex

The application error message suggests it expects:

resources/bin/codex

but the installed package appears to provide:

resources/codex.exe

I also tested the bundled executable:

app\resources\codex.exe

but executing it directly results in:

ResourceUnavailable
NativeCommandFailed
Access denied

Workaround:

The issue can be temporarily bypassed by installing the standalone Codex CLI and setting:

CODEX_CLI_PATH

to the native executable:

C:\Users\lenovo\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe

After restarting the Windows session and launching Codex Desktop again, the application can locate the CLI successfully.

Expected behavior:

Codex Desktop should either:

  1. Correctly locate the bundled CLI binary automatically.

or

  1. Correctly respect CODEX_CLI_PATH during startup.

Possible root cause:

The Windows Electron/MSIX package or startup logic may have a mismatch between the expected CLI location:

resources/bin/codex

and the actual packaged file:

resources/codex.exe

Suggested fixes:

  • Ensure the Windows package includes the expected resources/bin/codex binary.
  • Fix the startup path resolution logic.
  • Ensure CODEX_CLI_PATH is consistently respected on Windows.
  • Provide a clearer error message or repair guidance when the bundled binary cannot be executed.

Thank you for investigating this Windows issue.

What steps can reproduce the bug?

Possible root cause:

The Windows Electron/MSIX package or startup logic may have a mismatch between the expected CLI location:

resources/bin/codex

and the actual packaged file:

resources/codex.exe

Suggested fixes:

  • Ensure the Windows package includes the expected resources/bin/codex binary.
  • Fix the startup path resolution logic.
  • Ensure CODEX_CLI_PATH is consistently respected on Windows.
  • Provide a clearer error message or repair guidance when the bundled binary cannot be executed.

Thank you for investigating this Windows issue.

What is the expected behavior?

Expected behavior:

Codex Desktop should either:

  1. Correctly locate the bundled CLI binary automatically.

or

  1. Correctly respect CODEX_CLI_PATH during startup.

Additional information

No response

Activity

  1. added
    app
    on Aug 26, 2026
  2. added
    bug
    windows-os
    on Aug 26, 2026
  3. selfrestart commented on Aug 27, 2026

    @selfrestart

    I hit the exact same issue and want to add a second confirmed data point for the CODEX_CLI_PATH workaround.

    Environment:

    • OS: Windows 11 x64 (NT 10.0.26200.0)
    • App: ChatGPT / Codex Desktop (MSIX, 26.820.x)
    • Standalone CLI: codex-cli 0.150.1, installed globally via npm (@openai/[email protected])

    Symptoms:

    • Command line works fine (codex --version → codex-cli 0.150.1).
    • ChatGPT Desktop fails at startup with: "Unable to locate the Codex CLI binary. Set CODEX_CLI_PATH or ensure the Electron resources include bin/codex."
    • The npm-installed binary lives at:
      D:\Node.js\node_global\node_modules@openai\codex\node_modules@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe

    Workaround confirmed:
    Setting the user environment variable:
    CODEX_CLI_PATH=D:\Node.js\node_global\node_modules@openai\codex\node_modules@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe
    then fully quitting and relaunching ChatGPT Desktop fixed the issue. So this workaround is reproducible by more than one user.

    Additional observation (possible release pipeline issue):
    While debugging, I also found that @openai/[email protected] on npm initially declared npm:@openai/[email protected] in its optionalDependencies, but that version was missing from the registry (404) — the win32-x64 dist-tag only pointed to 0.150.0-win32-x64. It was published shortly after, and reinstalling (npm install -g @openai/codex@latest --include=optional) then installed the native binary correctly. Worth double-checking that platform packages always ship together with the main package.

    The bundled-binary relocation bug still needs a proper fix, but this workaround is solid in the meantime. Thanks for the report!

  4. Andu180 commented on Sep 6, 2026

    @Andu180

    Update: reproduced again on a newer Windows Codex Desktop build, but this time the failure had a second stage beyond CODEX_CLI_PATH.

    Environment

    • Windows 11 x64
    • Microsoft Store / MSIX package: OpenAI.Codex 26.901.5280.0
    • Package status: Ok

    Initial state

    The desktop app would not create a visible window. Several ChatGPT.exe processes were running and responsive, but every process had:

    MainWindowHandle = 0
    MainWindowTitle  = <empty>
    

    CODEX_CLI_PATH was already set to the current in-package CLI:

    C:\Program Files\WindowsApps\OpenAI.Codex_26.901.5280.0_x64__2p2nqsd0c76g0\app\resources\codex.exe
    

    A relocated per-user CLI also existed at:

    %LOCALAPPDATA%\OpenAI\Codex\bin\27d6a192e9c98618\codex.exe
    

    So the problem was no longer simply “CLI missing”.

    Key finding: cua_node runtime never finalized

    Under:

    %LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node
    

    I found multiple staging directories for the same new runtime content ID:

    .staging-440c4f095d41ea30-0jfzFT
    .staging-440c4f095d41ea30-7tMmyQ
    .staging-440c4f095d41ea30-fchxFW
    .staging-440c4f095d41ea30-oYcw3A
    .staging-440c4f095d41ea30-sa6T0U
    

    but there was no finalized:

    440c4f095d41ea30
    

    An older finalized runtime (426e88130fe66c7e) was still present.

    This strongly matched the recent Windows cua_node staging/finalization failures reported in #42484 and the protected-file / node_repl.exe relocation failures in #41540.

    Recovery that worked

    With Codex/ChatGPT fully stopped:

    1. Removed the failed .staging-440c4f095d41ea30-* directories.
    2. Used the current MSIX runtime source:
    <InstallLocation>\app\resources\cua_node
    
    1. Materialized the complete runtime directly into:
    %LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node\440c4f095d41ea30
    

    using xcopy /G so protected MSIX files could be written to a decrypted destination:

    xcopy.exe "$src\*" "$final\" /E /H /I /Y /G /Q
    1. Verified both:
    bin\node.exe
    bin\node_repl.exe
    

    were present and node.exe --version ran successfully.
    5. Relaunched Codex Desktop.

    After that, the desktop UI opened normally again.

    Conclusion

    On 26.901.5280.0, setting CODEX_CLI_PATH alone was not sufficient on this machine. The app could still remain headless because the new cua_node runtime repeatedly materialized into .staging-* directories but never finalized to its content-addressed directory.

    This appears to be part of the same Windows MSIX/Application Protected runtime-relocation family as #41540 / #42484, rather than only the original CLI path-resolution bug in this issue.

    I did not modify ownership/ACLs under WindowsApps. The successful recovery only rebuilt the per-user runtime cache under %LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node.

  5. Andu180 commented on Sep 8, 2026

    @Andu180

    Update: issue reproduced again on 26.901.6511.0 and recovered by rebuilding the new cua_node runtime

    The same Windows Desktop startup failure reproduced again after another Microsoft Store update.

    Environment on this recurrence:

    • Codex Desktop: 26.901.6511.0
    • Install location: C:\Program Files\WindowsApps\OpenAI.Codex_26.901.6511.0_x64__2p2nqsd0c76g0
    • User CODEX_CLI_PATH was updated to the current in-package binary:
      ...\app\resources\codex.exe

    Observed runtime state:

    • New cua_node content ID: b474a88d5d105afa
    • Multiple failed staging directories were created:
      • .staging-b474a88d5d105afa-a87obA
      • .staging-b474a88d5d105afa-EldW7e
      • .staging-b474a88d5d105afa-TrJ6T5
    • The finalized b474a88d5d105afa runtime directory did not exist while the app was failing to open.

    Recovery steps that worked:

    1. Fully stop ChatGPT.exe / Codex.exe.
    2. Detect the newest .staging-<hash>-* directory and extract the current runtime hash automatically instead of hard-coding the previous hash.
    3. Remove failed staging directories for that hash.
    4. Rebuild the full runtime from:
      app\resources\cua_node
      into:
      %LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node\b474a88d5d105afa
      using xcopy /E /I /H /Y /G.
    5. Relaunch Codex Desktop.

    The full copy looked stalled because /Q suppresses file output, but it was actually progressing normally. During the copy, the destination increased from roughly 1,532 to 1,907 files in ~23 seconds, and the packaged runtime contained about 4,683 files total. After the copy completed, the desktop app opened successfully again.

    This recurrence is important because it shows the workaround is not durable across Store updates: the runtime content hash changes, so a previously repaired runtime (for example the earlier 440c4f095d41ea30) does not prevent a later build from failing on a new hash (b474a88d5d105afa).

    So there appear to be two separate update-sensitive layers on Windows:

    1. CODEX_CLI_PATH may need to track the current versioned MSIX package path.
    2. cua_node materialization/finalization may fail again for each new runtime content ID.

    A durable product fix should make both the CLI resolution and bundled runtime relocation independent of versioned package paths / per-update manual repair, and should provide visible progress or bounded retries while the ~4.6k-file runtime is being materialized.

  6. 240409949 commented on Oct 26, 2026

    @240409949

    Additional Windows data point: removing a stale CODEX_CLI_PATH override restored startup on Microsoft Store Codex Desktop 26.1021.3705.0.

    After an automatic update, the user-level variable still pointed to the previous package version, 26.1013.4894.0. That executable no longer existed, while the current package's app\resources\codex.exe did exist. The app displayed "Unable to load organization settings."

    Updating the override to the current package path restored startup, but this workaround had to be repeated after updates.

    I then removed the user-level variable:

    [Environment]::SetEnvironmentVariable('CODEX_CLI_PATH', $null, 'User')

    After rebooting Windows, Codex started normally. The variable was confirmed absent from User, Machine, and Process scopes. No runtime cache rebuild was performed.

    Startup without the override is now confirmed on this machine; behavior after the next automatic update has not yet been verified. The original source of the override is unknown.

    Showing the selected CLI path and underlying launch error would help distinguish this case from actual organization-policy or network failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions