Skip to content

Windows self-update reports success but npm cleanup fails with EPERM unlinking codex.exe #21872

Open

Description

@luckyabsoluter

What version of Codex CLI is running?

codex-cli 0.130.0

What subscription do you have?

No relational

Which model were you using?

No response

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

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

PowerShell pwsh

What issue are you seeing?

On Windows, the built-in Codex update flow appears to complete successfully. The installed Codex version is updated, and Codex prints:

🎉 Update ran successfully! Please restart Codex.

However, during the update, the underlying npm install -g @openai/codex command emits an npm cleanup warning and leaves behind a temporary .codex-* directory under the npm global package directory.

The problem is not that the update failed. The problem is that the successful update leaves garbage files behind, including a staged copy of the Windows native codex.exe binary that npm could not remove.

What steps can reproduce the bug?

This was reproduced on a Windows GitHub Actions runner.

  1. Install an older Codex version globally:

     npm install -g @openai/[email protected]
    
  2. Run Codex and trigger the built-in update flow.

  3. Codex runs:

     npm install -g @openai/codex
    
  4. Observe the update output.

Actual output

    Updating Codex via `npm install -g @openai/codex`...
    npm warn cleanup Failed to remove some directories [
    npm warn cleanup   [
    npm warn cleanup     'C:\npm\prefix\node_modules\@openai\.codex-qgGaTSRE',
    npm warn cleanup     [Error: EPERM: operation not permitted, unlink 'C:\npm\prefix\node_modules\@openai\.codex-qgGaTSRE\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:\npm\prefix\node_modules\@openai\.codex-qgGaTSRE\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\codex\codex.exe'
    npm warn cleanup     }
    npm warn cleanup   ]
    npm warn cleanup ]
    changed 2 packages in 5s
    🎉 Update ran successfully! Please restart Codex.

What is the expected behavior?

Codex self-update should complete cleanly on Windows without leaving behind temporary .codex-* directories.

There should be no npm cleanup warning such as EPERM: operation not permitted, unlink ... codex.exe.

At minimum, the updater should report that the update completed but cleanup failed, and suggest closing running Codex processes or manually removing the leftover temporary .codex-* directory.

Additional information

name: Reproduce Codex self-update EPERM on Windows

on:
  push:
  workflow_dispatch:

jobs:
  repro:
    runs-on: windows-latest

    steps:
      - name: Show environment
        shell: pwsh
        run: |
          node --version
          npm --version
          whoami

      - name: Install Codex 0.128.0
        shell: pwsh
        run: |
          npm install -g @openai/[email protected]
          codex --version
          npm root -g
          Get-Command codex | Format-List *

      - name: Run Codex self-update
        shell: pwsh
        continue-on-error: true
        run: |
          codex update

      - name: Print npm logs
        if: always()
        shell: pwsh
        run: |
          $dirs = @(
            "$env:LOCALAPPDATA\npm-cache\_logs",
            "$env:APPDATA\npm-cache\_logs"
          )

          foreach ($dir in $dirs) {
            Write-Host "Checking $dir"
            if (Test-Path $dir) {
              Get-ChildItem $dir -Filter "*.log" |
                Sort-Object LastWriteTime -Descending |
                Select-Object -First 10 |
                ForEach-Object {
                  Write-Host "`n===== $($_.FullName) ====="
                  Get-Content $_.FullName -Tail 300
                }
            }
          }

      - name: Verify final Codex version
        if: always()
        shell: pwsh
        run: |
          codex --version
          npm list -g @openai/codex

Activity

  1. added
    bug
    on May 9, 2026
  2. added
    CLI
    windows-os
    on May 9, 2026
  3. github-actions commented on May 9, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. luckyabsoluter commented on May 9, 2026

    @luckyabsoluter
    Author

    The problem is not that the update failed. The problem is that the successful update leaves garbage files behind, including a staged copy of the Windows native codex.exe binary that npm could not remove.

  5. scheatham-citadel commented on Jun 17, 2026

    @scheatham-citadel

    Still reproduces on codex-cli 0.140.0 on Windows.

    Running codex update completes successfully but still emits the npm cleanup warning:

    EPERM: operation not permitted, unlink
    C:\Users<user>\AppData\Roaming\npm\[email protected]...\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 and
    looks like the updater is still trying to clean up a locked Codex executable.

  6. M57ax commented on Sep 26, 2026

    @M57ax

    I’m experiencing a similar issue on Windows, but in my case the installed version does not seem to update at all.

    The update command reports:

    🎉 Update ran successfully! Please restart Codex.

    but during the update I also get an EPERM error because codex.exe cannot be removed.

    After restarting Codex, codex --version still shows 0.137.0. I tried the update multiple times and the behavior is always the same.

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