Skip to content

Windows: Desktop fails to start after auto-update - stale per-user backend (CODEX_CLI_PATH) and silently invalidated auth session #46155

Open

Description

@hxtao1001

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

26.911.7940.0 (Windows package OpenAI.Codex_26.911.7940.0_x64__2p2nqsd0c76g0); bundled CLI in use: codex-cli 0.154.0-alpha.6.2

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows 11 Pro, Build 26200, x64

What issue are you seeing?

After the Codex desktop app auto-updated, it failed to start: no window appeared for 4+ minutes while the main process burned CPU continuously.

Two independent root causes were found on this machine.

  1. Stale bundled CLI in the per-user runtime directory

The app launches the executable selected by the user-level CODEX_CLI_PATH override, which points at the per-user runtime copy:
C:\Users<user>.codex.sandbox-bin\codex.exe

The MSIX package update only replaces the payload under C:\Program Files\WindowsApps\ and does NOT refresh this per-user copy. After the last update, all four backend binaries in .sandbox-bin differed from the ones bundled in the updated package - and comparing file sizes alone is not enough, because several differ in content while having identical sizes:

  • codex.exe: size identical, content differs
  • codex-code-mode-host.exe: differs (72,471,848 vs 72,471,856)
  • codex-command-runner.exe: size identical, content differs
  • codex-windows-sandbox-setup.exe: size identical, content differs

The app gave no indication it was running a stale app-server; startup simply hung.

  1. Auth session silently invalidated, while login status still reports "logged in"

codex login status reported "Logged in using ChatGPT", while the stored tokens were unusable. Refreshing returned HTTP 401:
{"error":{"message":"Your session has ended. Please log in again.","code":"refresh_token_invalidated"}}

The id_token was expired and the refresh_token had been revoked server-side (the machine had been idle for several days). Nothing in the UI surfaced this - the app just failed to start.

What steps can reproduce the bug?

  1. Use Codex Desktop on Windows with a user-level CODEX_CLI_PATH set. This override is the documented workaround for the "Unable to locate the Codex CLI binary" startup failure (see [Windows 26.820] Codex Desktop cannot start: bundled codex.exe relocation from WindowsApps fails #40700 / [Bug] Windows Desktop app fails to start after update to v26.820.60940 ("Unable to locate Codex CLI" & spawn EINVAL on .cmd wrapper) #40752 / [Windows Desktop] Stale CODEX_CLI_PATH after app update breaks paginated thread restore #40796).
  2. Let the app auto-update through the MSIX store while the override is in place.
  3. Fully exit and relaunch the app.
  4. Observe: no window appears and the main process consumes CPU indefinitely.
  5. Compare each .exe under %USERPROFILE%.codex.sandbox-bin against the same-named file under the updated package's app\resources directory - hashes differ even when file sizes match.
  6. Separately, leave the app unused for several days and relaunch: codex login status still says logged in, but POST https://auth.openai.com/oauth/token with grant_type=refresh_token returns 401 refresh_token_invalidated.

What is the expected behavior?

  1. When the desktop app updates, it should validate the version and/or protocol capabilities of the app-server binary it is about to launch (including one selected via CODEX_CLI_PATH), and either refresh it automatically or refuse to start with an actionable error naming the configured path and the detected version mismatch - instead of hanging silently.

  2. Before opening a thread, the app should verify that stored credentials are still usable (e.g. probe the refresh endpoint). If the session has been invalidated server-side, it should prompt the user to sign in again, instead of continuing to report codex login status: Logged in using ChatGPT.

Additional information

No response

Activity

  1. added
    app
    on Sep 17, 2026
  2. added
    bug
    windows-os
    app-server
    auth
    on Sep 17, 2026
  3. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. jhclarke90 commented on Sep 19, 2026

    @jhclarke90

    Confirming this on a second machine, and I think I can add the mechanism.

    Same environment as the report — Windows 11 Pro 26200, x64, MSIX install. I've hit this on eight
    consecutive updates
    since 3 September, and the staging directory was verified fully hash-correct
    immediately after each repair, so every occurrence starts from a known-good state.

    One difference worth noting: my per-user copy is %USERPROFILE%\.codex\plugins\.plugin-appserver\
    rather than .sandbox-bin\, and my CODEX_CLI_PATH pins …\.plugin-appserver\codex.exe. Same
    four binaries, same failure, so I suspect one root cause behind both directories. #40817 looks like
    the same bug again.

    Mechanism

    Three things from the shipped bundle:

    hY = ".plugin-appserver"                                               // staging dir
    ExecutableNames: e.executableName === "codex" ? ["codex-code-mode-host"] : []
    _Y = [0, 100, 200, 400, 800]                                           // retry backoff, ms

    codex-code-mode-host is not a staging entry of its own — it's a companion of the codex
    entry.
    So any failure staging codex.exe silently takes the host binary down with it. That's what
    escalates "stale app-server" into "no terminal at all", and it explains why these two specific files
    are the ones that break.

    Staging looks like delete-then-copy, and isn't atomic. One model fits every occurrence:

    • file not locked → unlink succeeds → the copy never happens → ends up absent
    • file locked (codex.exe, running as the app-server) → unlink fails EPERM → old build
      survives → ends up stale

    That's exactly the split I see every time: codex.exe stale, the others absent. Logged 16 times on
    3 Sept and 3 times on 6 Sept:

    EPERM: operation not permitted, unlink
      'C:\Users\<user>\.codex\plugins\.plugin-appserver\codex.exe'
    

    The strongest evidence for delete-then-copy: on 4 Sept codex-command-runner.exe and
    codex-windows-sandbox-setup.exe were verified present and hash-correct. On 6 Sept both were
    absent, with no replacement written. Files that existed were removed and not replaced.

    Related: EPERM unlinking a locked codex.exe during self-update is already open as #21872 and
    #23320 in the npm/CLI path, since May. Probably the same underlying problem in a different updater.

    Occurrences

    Date Updated to codex.exe code-mode-host command-runner sandbox-setup
    09-03 26.901.1978.0 stale absent written written
    09-04 26.901.4073.0 stale absent unchanged unchanged
    09-06 26.901.6511.0 stale absent absent absent
    09-09 26.903.8094.0 stale absent absent absent
    09-11 26.903.9818.0 stale OK OK OK
    09-14 26.908.4834.0 stale absent OK absent
    09-16 26.908.9136.0 stale absent OK absent
    09-18 26.915.3509.0 stale absent OK OK

    codex.exe has been wrong 8 times out of 8. Restarting the app never fixes it — the app launches
    its app-server from the staged codex.exe, loading and locking it, and only then runs the refresh
    that needs to replace it.

    Two traps for anyone reproducing this:

    • Compare hashes, not sizes. On 09-09 and 09-16 the stale codex.exe was byte-identical in
      size to the package copy but differed by SHA-256 — matching the "identical size, different
      content" note in the original report.
    • A "match" can be a false positive. On 09-04 the two helpers were byte-identical across both
      builds, so they matched whether or not anything was written. Only when they changed between builds
      did it become visible that they were absent.

    Suggested fixes

    1. Never remove a binary before its replacement is in hand — copy to a temp name and rename over
      the target (MoveFileEx + MOVEFILE_REPLACE_EXISTING, falling back to
      MOVEFILE_DELAY_UNTIL_REBOOT for a locked target). This alone would fix it.
    2. Stage before launching the app-server, not after — the app currently creates the lock that
      defeats its own refresh.
    3. Make codex-code-mode-host its own staging entry, so it can't be taken down by a sibling's
      failure.
    4. Surface the staging failure. Five retries are exhausted silently and the user is shown the
      downstream os error 2 instead. That's what makes this so hard to diagnose.

    Reproduction / verification without the GUI

    codex sandbox whoami      # fails when the host binary is missing
    codex doctor --summary    # reports ✗ sandbox
    

    Workaround — fully quit the app first, then:

    $src = (Get-AppxPackage OpenAI.Codex).InstallLocation + "\app\resources"
    $dst = "$env:USERPROFILE\.codex\plugins\.plugin-appserver"
    "codex.exe","codex-code-mode-host.exe","codex-command-runner.exe","codex-windows-sandbox-setup.exe" |
      ForEach-Object { Copy-Item "$src\$_" "$dst\$_" -Force }

    Not endpoint security

    Pre-empting the obvious triage: this machine runs CrowdStrike Falcon with Defender AV disabled, but
    it isn't an EDR problem. The "missing" binary survives untouched with an identical SHA-256 in both
    the MSIX package and %LOCALAPPDATA%\OpenAI\Codex\bin\<hash>\ — a conviction would have removed
    every copy. And quarantine can't produce a stale codex.exe rather than a deleted one.

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

    appapp-serverauthbugperformancewindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions