Skip to content

Windows global npm update can leave codex-win32-x64 stale after @openai/codex update #19824

Open

Description

@MarekProkop

What version of Codex CLI is running?

After the problematic update, codex --version still returned:

ext codex-cli 0.124.0

The main npm package was already updated to @openai/[email protected].

What subscription do you have?

ChatGPT Pro

Which model were you using?

N/A - install/update issue before normal use.

What platform is your computer?

Windows x64

ext Microsoft Windows NT 10.0.26200.0 Node.js v22.13.0 npm 11.10.0 PowerShell npm global prefix: C:\usr\local

What issue are you seeing?

Updating Codex globally with npm can report success while leaving the native Windows platform package stale or partially replaced.

In this case, after updating to @openai/[email protected], the JS wrapper package was updated but the native package used by the wrapper was still effectively 0.124.0, so running codex --version continued to report codex-cli 0.124.0.

Observed state during investigation:

` ext
C:\usr\local\node_modules@openai\codex\package.json
version: 0.125.0

C:\usr\local\node_modules@openai\codex-win32-x64\package.json
version: 0.124.0-win32-x64

codex --version
codex-cli 0.124.0
`

A later direct reinstall attempt of the platform alias also left the global install in an incomplete/staging state for a while:

ext C:\usr\local\node_modules\@openai\.codex-win32-x64-ZLHIbqty C:\usr\local\node_modules\@openai\codex-win32-x64

At one point the target package existed but codex failed with:

ext Error: Missing optional dependency @openai/codex-win32-x64. Reinstall Codex: npm install -g @openai/codex@latest

The

Activity

  1. added
    bug
    CLI
    windows-os
    on Apr 27, 2026
  2. github-actions commented on Apr 27, 2026

    @github-actions
    Contributor
  3. FSudong commented on Sep 13, 2026

    @FSudong

    I reproduced the destructive variant of this on Windows with the current 0.154.0 release. This is more than a stale-binary/cleanup warning: the updater reported success while leaving the CLI unable to start.

    Environment:

    • Windows x64 (Windows_NT 10.0.26200)
    • Node.js v24.15.0
    • npm 11.12.1
    • @openai/[email protected]
    • no omit=optional configuration; registry is https://registry.npmjs.org/

    The update was run from an active Codex process. The npm debug log shows this sequence:

    silly reify mark retired [
      'C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\codex',
      ...
    ]
    http cache @openai/codex-win32-x64@https://registry.npmjs.org/@openai/codex/-/codex-0.154.0-win32-x64.tgz 0ms (cache hit)
    verbose reify failed optional dependency C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64
    warn cleanup Failed to remove some directories [
      Error: EPERM: operation not permitted, unlink
      'C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\.codex-<id>\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe'
    ]
    verbose exit 0
    info ok
    

    After that successful exit, the installed tree contained @openai/[email protected] but no @openai/codex-win32-x64. Every launch failed with:

    Error: Missing optional dependency @openai/codex-win32-x64.
    Reinstall Codex: npm install -g @openai/codex@latest
    

    This connects the Windows executable-lock behavior in #21872/#23320 with npm's silent optional-dependency failure in #41283. run_update_action waits for npm install -g @openai/codex while the native Windows executable being replaced is still alive. Windows locks that executable; npm can suppress the platform-package failure because it is an optionalDependency, then Codex treats npm's exit code 0 as a successful update.

    Suggested fix direction:

    1. Do not run npm/pnpm/bun self-update synchronously from the active native Codex process on Windows. Exit first and hand the update to a detached helper that waits for the old process to release the executable (or, as a minimal safe fallback, tell the user to run the command after exiting).
    2. Before printing Update ran successfully, launch the newly installed codex --version through the resolved global shim and require success.
    3. Independently harden the npm package installation path so absence of the current platform package cannot produce a successful install (for example, a post-install platform-binary verification or a packaging design where the selected binary is required rather than optional).

    The official standalone Windows installer already avoids this class of failure by installing into a versioned release directory, validating the package contents/version, and only then switching the current junction. Migrating the Windows update action to that installer may be the cleanest long-term fix.

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

    CLIbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions