codex - 💡(How to fix) Fix Windows: codex update leaves npm cleanup warning because codex.exe is locked

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

not available

codex doctor --json does not appear to be supported in codex-cli 0.130.0. Running it returns:

error: unexpected argument '--json' found

Root Cause

When running codex update from inside an active Codex CLI session on Windows, Codex updates via npm install -g @openai/codex, but npm then emits cleanup warnings because it cannot remove a temporary install directory containing codex.exe.

Code Example

not available

`codex doctor --json` does not appear to be supported in codex-cli 0.130.0. Running it returns:

error: unexpected argument '--json' found
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.130.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.5

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

Windows Terminal 1.24.11321.0 PowerShell 7.6.1 No terminal multiplexer.

Codex doctor report

not available

`codex doctor --json` does not appear to be supported in codex-cli 0.130.0. Running it returns:

error: unexpected argument '--json' found

What issue are you seeing?

When running codex update from inside an active Codex CLI session on Windows, Codex updates via npm install -g @openai/codex, but npm then emits cleanup warnings because it cannot remove a temporary install directory containing codex.exe.

Observed output:

npm warn cleanup Failed to remove some directories [ npm warn cleanup [ npm warn cleanup 'C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\.codex-l0XzpfJG', npm warn cleanup [Error: EPERM: operation not permitted, unlink 'C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\.codex-l0XzpfJG
\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\codex\codex.exe'] { npm warn cleanup errno: -4048, npm warn cleanup code: 'EPERM', npm warn cleanup syscall: 'unlink', npm warn cleanup path: 'C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\.codex-l0XzpfJG\node_modules\@openai\codex-win32-x64
\vendor\x86_64-pc-windows-msvc\codex\codex.exe' npm warn cleanup } npm warn cleanup ] npm warn cleanup ]

The update appears to complete, but the warning is confusing and leaves temporary .codex-* install directories behind.

What steps can reproduce the bug?

  1. On Windows, open Codex CLI in Windows Terminal / PowerShell.
  2. Start or continue an interactive Codex CLI session.
  3. Run codex update through Codex.
  4. Observe that the update invokes npm install -g @openai/codex.
  5. After installation, npm emits cleanup warnings with EPERM: operation not permitted, unlink ... codex.exe.

Uploaded thread: 019e3b9c-2a56-7412-a69d-9df4d7172591

What is the expected behavior?

codex update should work as a Windows-safe self-update without producing npm cleanup warnings and without leaving temporary .codex-* directories behind.

If the running Codex process prevents immediate cleanup, the updater should use a Windows-safe strategy such as a separate updater process, side-by-side versioned install, deferred cleanup, or another mechanism that does not try to remove the active codex.exe.

Additional information

This seems specific to the self-update path on Windows. Other tools avoid this class of issue by delegating the update to a separate process, using versioned side-by-side installs, or deferring cleanup until the running executable is no longer locked.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Windows: codex update leaves npm cleanup warning because codex.exe is locked