Skip to content

Windows: codex update leaves npm cleanup warning because codex.exe is locked #23320

@ufthygygh

Description

@ufthygygh

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\\AppData\Roaming\npm\node_modules\@openai\.codex-l0XzpfJG',
npm warn cleanup [Error: EPERM: operation not permitted, unlink 'C:\Users\\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\\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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions