Windows: codex update leaves npm cleanup warning because codex.exe is locked
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?
- On Windows, open Codex CLI in Windows Terminal / PowerShell.
- Start or continue an interactive Codex CLI session.
- Run
codex updatethrough Codex. - Observe that the update invokes
npm install -g @openai/codex. - 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.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Still reproduces on codex-cli 0.140.0 on Windows.
Running
codex updatecompletes successfully but still emits the npm cleanup warning:EPERM: operation not permitted, unlink
C:\Users\<user>\AppData\Roaming\npm\node_modules\@openai\.codex-...\node_modules\@openai\codex-win32-
x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe
The stale
.codex-*temp directory is recreated each time. The update succeeds, but the warning remains confusing andlooks like the updater is still trying to clean up a locked Codex executable.
Additional reproduction from a Windows/nvm install on 2026-06-30.
Environment observed:
codex-cli 0.142.4npm install -g @openai/codex11.12.1 -> 11.18.0C:\Users\<user>\AppData\Local\nvm\v25.9.0\node_modules\@openai\...codexCLI process was present.Observed warning:
Post-update checks:
codex --versionreturnscodex-cli 0.142.4, so the update itself appears to succeed....\node_modules\@openai\.codex-dZHYjNjNafter the update.This looks consistent with the running Windows executable/package binary being locked during npm's cleanup phase.
I can reproduce this Windows npm cleanup warning on
codex-cli 0.142.4.In my environment,
codex updatesucceeds, but npm prints:I also confirmed that manually deleting the stale
.codex-*directory after the update succeeds, so the lock appears to be transient while the oldcodex.exeis still running.I investigated a possible fix and prepared a small branch here:
https://github.com/tomooch/codex/tree/fix-windows-npm-update-cleanup
Approach:
codex.exemay still be locked.node_modules/@openaidirectory fromcurrent_exe()instead of hardcoding%APPDATA%..codex-*directories directly under that derived@openaidirectory.Validation:
cargo fmt -p codex-clicargo test -p codex-cli --bin codexcargo check -p codex-clicargo clippy -p codex-cli --testscargo check -p codex-cli: passedcargo clippy -p codex-cli --tests: passedcargo test -p codex-cli --bin codex derives_npm_openai_dir_from_exe: passedcargo test -p codex-cli --bin codex builds_delayed_cleanup_script: passedcargo test -p codex-cli --bin codex: compiled and ran; 216 passed, 1 unrelateddoctor::thread_inventorytest failedGiven the contributing guidelines say external PRs are by invitation only, I have not opened a PR yet. If this approach aligns with the intended direction, I’d be happy to open a focused PR.
Try After exiting Codex/IDE, execute in standalone PowerShell:
Dear Sir,
The command you provided did not work. The archived chats are stored in the cloud, and as shown in the attached screenshot, there is no option to delete them.
Could you please advise me on how to permanently delete these archived chats?
Best regards,
@.***
From: 周思伟 @.*>
Sent: Wednesday, July 29, 2026 10:39 AM
To: openai/codex @.*>
Cc: txchiang @.>; Comment @.>
Subject: Re: [openai/codex] Windows: codex update leaves npm cleanup warning because codex.exe is locked (Issue #23320)
[影像被寄件者移除。]JoeyBling left a comment (openai/codex#23320)<https://github.com/openai/codex/issues/23320#issuecomment-5112163031>
Try After exiting Codex/IDE, execute in standalone PowerShell:
Get-Process -Name codex,codex-code-mode-host -ErrorAction SilentlyContinue | Stop-Process -Force
—
Reply to this email directly, view it on GitHub<https://github.com/openai/codex/issues/23320?email_source=notifications&email_token=APNHHKPR7K6RJQUVMJUZUED5HFPT7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJRGIYTMMZQGMY2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5112163031>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APNHHKI3KCMZFR65OAVXXCD5HFPT7AVCNFSNUABFKJSXA33TNF2G64TZHM4TMNJUGE2TMNBZHNEXG43VMU5TINBXGA2TIMZXGEZKC5QC>.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS<https://github.com/notifications/mobile/ios/APNHHKK5IQX5K3UJRSV247T5HFPT7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJRGIYTMMZQGMY2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y> and Android<https://github.com/notifications/mobile/android/APNHHKIVX2E2DNYA2XEHOVD5HFPT7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJRGIYTMMZQGMY2M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>. Download it today!
You are receiving this because you commented.Message ID: @.***>