Windows sandbox regression in Codex CLI 0.138.0: setup refresh fails with os error 740 / CreateProcessAsUserW failed: 2; 0.132.0 works

Resolved 💬 16 comments Opened Jun 3, 2026 by BaseBlank Closed Jun 12, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

Failing version: codex-cli 0.136.0 Working rollback version: codex-cli 0.132.0 I am currently staying on 0.132.0 because it restores Windows sandbox execution.

What subscription do you have?

ChatGPT PRO

Which model were you using?

gpt-5.5

What platform is your computer?

Windows 11 x64. Approximate environment: Windows 11 x64, version 25H2 / build 26200.x

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

PowerShell 7.6.2 No tmux/screen/zellij. Codex installed through npm global install.

Codex doctor report

Codex Doctor v0.136.0 · windows-x86_64

Environment:
  system: en
  runtime: npm
  install: consistent
  search: bundled rg.exe found
  git: git version 2.54.0.windows.1
  terminal: Windows Terminal
  state: databases healthy

Configuration:
  config: loaded
  auth: configured
  mcp: 1 server configured
  sandbox: restricted fs + restricted network · approval OnRequest

Updates:
  update configuration is locally consistent

Connectivity:
  network-related environment looks readable
  websocket: connected
  active provider endpoints are reachable over HTTP

Background Server:
  app-server not running (ephemeral mode)

Summary:
  16 ok · 1 idle · 1 notes · 1 warn · 0 fail · degraded

The only warning was:

threads: rollout scan was incomplete or found bad files

The doctor report did not show a failed installation, auth, network, or sandbox helper check.

I am not pasting the full raw JSON here because it contains local filesystem paths. I can provide a redacted JSON report if needed.

What issue are you seeing?

After upgrading Codex CLI to 0.136.0 on Windows, sandboxed command execution started failing before the requested command actually ran.

The original user-facing failure inside Codex TUI was:

execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })

This happened even for simple read-only commands, for example:

Get-Location
Get-Content -Raw -LiteralPath .gitignore
Get-Content -Raw -LiteralPath README.md
Get-ChildItem -Force | Select-Object Name
cmd /c type .gitignore

Codex was not able to read .gitignore or README.md. This was not a .gitignore or project-file issue, because even Get-Location failed before PowerShell started.

The sandbox log showed repeated setup-refresh failures like this, with local paths redacted:

[REDACTED_TIME codex.exe] setup refresh: spawning %APPDATA%\npm\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\codex-resources\codex-windows-sandbox-setup.exe (cwd=<PROJECT_DIR>, payload_len=5296)

[REDACTED_TIME codex.exe] setup refresh: failed to spawn %APPDATA%\npm\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\codex-resources\codex-windows-sandbox-setup.exe: The requested operation requires elevation. (os error 740)

On my localized Windows system, the message was:

(os error 740)

I then tested the sandbox directly outside the TUI.

With codex-cli 0.136.0:

$cmd = "$env:WINDIR\System32\cmd.exe"

codex -c 'windows.sandbox="elevated"' sandbox windows $cmd /c echo CODEX_ELEVATED_OK

Observed:

windows sandbox failed: runner error: CreateProcessAsUserW failed: 2

Then:

codex -c 'windows.sandbox="unelevated"' sandbox windows $cmd /c echo CODEX_UNELEVATED_OK

Observed:

windows sandbox failed: CreateProcessAsUserW failed: 2

So after some troubleshooting, both elevated and unelevated modes failed on 0.136.0.

Important: codex doctor --summary reported 0 fails, so the install/config/network/auth state appeared healthy from doctor’s perspective.

Rollback fixed it:

npm install -g @openai/codex@0.132.0
codex --version

Output:

codex-cli 0.132.0

Then:

$cmd = "$env:WINDIR\System32\cmd.exe"
codex -c 'windows.sandbox="elevated"' sandbox windows $cmd /c echo CODEX_ROLLBACK_TEST_OK

Output:

CODEX_ROLLBACK_TEST_OK

This strongly suggests a Windows sandbox regression after 0.132.0, visible on my system with 0.136.0.

What steps can reproduce the bug?

On Windows 11 x64:

Install Codex CLI 0.136.0 globally through npm:
npm install -g @openai/codex@0.136.0
codex --version

Expected version output:

codex-cli 0.136.0
Use this relevant config:
approval_policy = "on-request"
sandbox_mode = "workspace-write"
approvals_reviewer = "user"

[sandbox_workspace_write]
network_access = false

[windows]
sandbox = "elevated"
Start Codex normally:
codex --sandbox workspace-write --ask-for-approval untrusted
Ask Codex to read simple local files:
Read .gitignore and README.md. Do not modify files. Report whether both reads succeeded.

Observed inside Codex:

execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })
Reproduce outside the TUI with a minimal command:
$cmd = "$env:WINDIR\System32\cmd.exe"

codex -c 'windows.sandbox="elevated"' sandbox windows $cmd /c echo CODEX_ELEVATED_OK
codex -c 'windows.sandbox="unelevated"' sandbox windows $cmd /c echo CODEX_UNELEVATED_OK

Observed on 0.136.0 after troubleshooting:

windows sandbox failed: runner error: CreateProcessAsUserW failed: 2
windows sandbox failed: CreateProcessAsUserW failed: 2

Earlier sandbox log entries also showed:

setup refresh: failed to spawn ...\codex-resources\codex-windows-sandbox-setup.exe: The requested operation requires elevation. (os error 740)
Roll back to 0.132.0:
npm install -g @openai/codex@0.132.0
codex --version
Retest elevated sandbox:
$cmd = "$env:WINDIR\System32\cmd.exe"
codex -c 'windows.sandbox="elevated"' sandbox windows $cmd /c echo CODEX_ROLLBACK_TEST_OK

Observed:

CODEX_ROLLBACK_TEST_OK

What is the expected behavior?

Codex CLI 0.136.0 should be able to run basic sandboxed commands on Windows in the elevated sandbox, especially commands such as:

cmd /c echo CODEX_ELEVATED_OK
Get-Location
Get-Content -Raw -LiteralPath .gitignore
Get-Content -Raw -LiteralPath README.md

At minimum, if sandbox setup cannot proceed, Codex should report a clear actionable diagnostic explaining which Windows setup step, helper executable, permission, AppCompat/UAC setting, or sandbox runner path failed.

The expected output for this test should be:

CODEX_ELEVATED_OK

Additional information

Troubleshooting already attempted:

Restarted the computer completely.
shutdown /r /f /t 0

Result: did not fix the issue.

Confirmed codex doctor --summary did not show installation/config/auth/network failures.

Result: doctor summary had 0 fail, but sandbox execution still failed.

Tested direct sandbox command execution outside the TUI.
$cmd = "$env:WINDIR\System32\cmd.exe"
codex -c 'windows.sandbox="elevated"' sandbox windows $cmd /c echo CODEX_ELEVATED_OK
codex -c 'windows.sandbox="unelevated"' sandbox windows $cmd /c echo CODEX_UNELEVATED_OK

Result on 0.136.0: failed.

Ran the official elevated sandbox setup command:
codex sandbox setup --elevated --current-user

A UAC prompt appeared for:

codex-windows-sandbox-setup.exe
Verified publisher: OpenAI OpCo, LLC

The command completed:

Windows elevated sandbox setup completed for <USER> at %USERPROFILE%\.codex.

Result: did not fix sandbox execution on 0.136.0.

Tried the narrow AppCompat RUNASINVOKER workaround for codex-windows-sandbox-setup.exe.

Result: this appeared to move the failure past the original os error 740, but sandbox execution still failed later with:

runner error: CreateProcessAsUserW failed: 2

So RUNASINVOKER was not a complete fix.

Tested without the -- separator in the sandbox command.

Result: still failed.

Tested both sandbox modes.

Result:

elevated -> CreateProcessAsUserW failed: 2
unelevated -> CreateProcessAsUserW failed: 2
Tested:
windows.sandbox_private_desktop = false

via command-line config:

codex -c 'windows.sandbox="elevated"'
-c 'windows.sandbox_private_desktop=false'

sandbox windows $cmd /c echo CODEX_ELEVATED_NO_PRIVATE_DESKTOP_OK

Result: still failed with CreateProcessAsUserW failed: 2.

Refreshed the runner cache by renaming:
%USERPROFILE%\.codex\.sandbox-bin

Result: still failed on 0.136.0.

Rolled back to 0.132.0.
npm install -g @openai/codex@0.132.0

Result: fixed the elevated Windows sandbox test:

CODEX_ROLLBACK_TEST_OK

Related existing issues that look similar:

https://github.com/openai/codex/issues/24391
https://github.com/openai/codex/issues/24050
https://github.com/openai/codex/issues/24098
https://github.com/openai/codex/issues/22428

What seems new/useful in this report:

The failure is confirmed on codex-cli 0.136.0.
codex doctor --summary reported no major failures.
codex sandbox setup --elevated --current-user completed successfully but did not fix it.
RUNASINVOKER only changed the failure mode; it did not restore execution.
windows.sandbox_private_desktop=false did not fix it.
Refreshing .sandbox-bin did not fix it.
Downgrading to codex-cli 0.132.0 restored elevated sandbox execution immediately.

View original on GitHub ↗

16 Comments

github-actions[bot] contributor · 1 month ago

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

  • #25876

Powered by Codex Action

BaseBlank · 1 month ago

Additional update: this still reproduces on Codex CLI 0.137.0 with the native Windows standalone installer, not only the npm install path.

````markdown

Version / install path tested

  • Codex CLI version: 0.137.0
  • Platform: Windows x64
  • Terminal: PowerShell 7.6.2 / Windows Terminal
  • Install method: official native Windows standalone installer:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
````

The installer completed successfully and reported:

```text
Detected platform: Windows (x64)
Resolved version: 0.137.0
Downloading Codex CLI
PATH updated for future PowerShell sessions.
Codex CLI 0.137.0 installed successfully.

After opening a new PowerShell session, where.exe codex resolved to the native standalone path:

%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe

So this reproduction does not appear to depend on npm’s global shim/package layout.

Observed failure on 0.137.0

After launching Codex normally in a project workspace, simple read-only file commands still failed before command execution. Example commands attempted by Codex:

Get-Content -Raw -LiteralPath .gitignore
Get-Content -Raw -LiteralPath README.md
Get-Content -Raw -LiteralPath <PROJECT_DIR>\.gitignore

Observed repeated error:

execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })

Codex then reported that the sandbox was failing before command execution:

The sandbox is still failing before command execution, so I'm going to request an unsandboxed read of only these two files in the workspace. No Git command or write operation is involved.

Then even a single safe read command still hit the same sandbox startup error:

Ran Get-Content -Raw -LiteralPath .gitignore
execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })

The session ultimately became unusable for normal read-only workspace inspection.

Why this is useful additional signal

The original report confirmed the regression on codex-cli 0.136.0 and that rollback to 0.132.0 restored sandbox execution.

This new test confirms that:

  • the same windows sandbox: spawn setup refresh failure still exists in 0.137.0;
  • the failure occurs after a successful native Windows standalone install;
  • the active codex.exe is the native install under %LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe;
  • simple read-only commands fail before PowerShell command execution;
  • this is not only an npm-managed install issue.

No private filesystem paths are included here; local project paths and user profile paths have been redacted or replaced with environment-variable placeholders.

BaseBlank · 1 month ago

````markdown

Additional fresh-install test on a brand-new Windows machine

I have a new reproduction from a brand-new Windows laptop, which makes the failure look broader than a normal “sandbox execution failed” bug. In this case, the Windows sandbox could not even complete its setup/refresh path successfully.

Fresh native Windows standalone install: codex-cli 0.137.0

Install path was the native standalone Windows install, not npm:

where.exe codex
# %LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe

codex --version
# codex-cli 0.137.0
````

`codex doctor --summary` looked healthy enough to be misleading:

```text
17 ok · 1 idle · 0 warn · 0 fail

The doctor output included a sandbox line that looked configured/healthy, but direct sandbox execution still failed.

Minimal direct sandbox test:

$cmd = "$env:WINDIR\System32\cmd.exe"

codex -c 'windows.sandbox="unelevated"' sandbox windows -- $cmd /c echo CODEX_UNELEVATED_OK

Observed result:

windows sandbox failed: CreateProcessAsUserW failed: 2

At the same time, Windows showed a system dialog for:

codex-windows-sandbox-setup.exe

with the localized Windows message equivalent to:

Windows cannot find 'codex-windows-sandbox-setup.exe'. Make sure you typed the name correctly, and then try again.

So in this fresh native-install case, the failure is not only that the sandbox blocks a command after setup. The setup/refresh helper itself appears not to be found/launched correctly, so the sandbox cannot be configured/refreshed successfully before the requested command even starts.

This is also not only an npm packaging issue, because this reproduction used the native standalone Windows path:

%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe

Rollback on the same machine: codex-cli 0.132.0 works

After rolling back to 0.132.0 on the same new machine:

codex --version
# codex-cli 0.132.0

where.exe codex
# %LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe

Both sandbox modes passed the same minimal smoke tests:

$cmd = "$env:WINDIR\System32\cmd.exe"

codex -c 'windows.sandbox="unelevated"' sandbox windows -- $cmd /c echo CODEX_UNELEVATED_OK
# CODEX_UNELEVATED_OK

codex -c 'windows.sandbox="elevated"' sandbox windows -- $cmd /c echo CODEX_ELEVATED_OK
# CODEX_ELEVATED_OK

Then normal file-read tool calls also worked again. This strongly narrows the regression to a post-0.132.0 Windows sandbox/helper packaging or helper resolution change.

Source-code / release-analysis hypothesis

Based on the public PR history, there appear to be two closely related failure classes:

  1. UAC manifest regression

PR #23764 removed Windows sandbox resource stamping. That PR removed the windows-sandbox-rs build script, the setup helper manifest, the winres dependency, and the Bazel build-script data for the manifest. Later, PR #25949 explicitly says #23764 also removed the setup helper’s UAC manifest and that the manifest was functionally important, not just cosmetic. PR #25949 restored a minimal requestedExecutionLevel level="asInvoker" manifest so setup refresh can use normal Command::new(...) without triggering UAC, while full setup can still intentionally use ShellExecuteExW with runas.

  1. Helper discovery / packaging / stale or incomplete binary directory regression

The new 0.137.0 native-install failure shown above is not the same as only os error 740. It is CreateProcessAsUserW failed: 2 plus a Windows dialog saying codex-windows-sandbox-setup.exe cannot be found. That points to a helper path/discovery/packaging problem: Codex is trying to launch the setup helper, but the helper is either missing from the resolved runtime directory or being resolved/launched from the wrong location. This looks related in class to #25322, where a Windows process could keep using a cached binary directory containing codex.exe but missing codex-windows-sandbox-setup.exe and codex-command-runner.exe.

The important new signal is that 0.137.0 still fails on a brand-new machine with the native standalone install, while 0.132.0 works immediately on the same machine and same install path. That suggests the manifest restoration in #25949 may have fixed the os error 740 variant, but it does not fully cover the helper-location / helper-packaging / setup-refresh path that produces CreateProcessAsUserW failed: 2 and “cannot find codex-windows-sandbox-setup.exe”.

Requested diagnostic improvement

codex doctor should probably verify the actual sandbox helper resolution path by checking that the exact runtime directory used by sandbox setup contains at least:

codex.exe
codex-windows-sandbox-setup.exe
codex-command-runner.exe

and then run a minimal setup-refresh smoke test, rather than reporting the sandbox as healthy while the first real sandbox command fails before process launch.

markski1 · 1 month ago

Same experience.

Windows 11 Pro 10.0.26200
Codex 0.138.0 npm install

Both elevated and unelevated Windows sandbox fail:
CreateProcessAsUserW failed: 2

Same machine, same command works on 0.132.0:

codex sandbox windows C:\Windows\System32\cmd.exe /c echo OK
=> OK
BaseBlank · 1 month ago
Same experience. Windows 11 Pro 10.0.26200 Codex 0.138.0 npm install `` Both elevated and unelevated Windows sandbox fail: CreateProcessAsUserW failed: 2 ` Same machine, same command works on 0.132.0: ` codex sandbox windows C:\Windows\System32\cmd.exe /c echo OK => OK ``

Yes, I tested the latest version 0.138 today, and it still hasn't even attempted to fix this bug. I looked at the code changes in the new version; there's no fix for this bug, only fixes for some sandbox error message logic. Currently the only workaround is to use version 0.132.0.

https://github.com/openai/codex/issues/27125

martinmclee · 1 month ago

I confirm this matches my report: shell/tool execution fails before command start with execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" }) and .codex/.sandbox logs show repeated setup refresh: failed to spawn ...codex-windows-sandbox-setup.exe: ... (os error 740) in elevated mode.

Repro in thread was rg --files and simple PowerShell commands inside Codex, while direct execution outside Codex succeeds.

CLI at repro: 0.137.0, and sandbox mode configured as elevated.

martinmclee · 1 month ago

Update: I updated to codex-cli 0.139.0, and the issue is still reproducing.

Current behavior in the Codex in-thread runner:

  • rg --files -> execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })
  • Get-Location -> same error
  • codex --version (run in-thread) -> same error

~/.codex/.sandbox/sandbox.2026-06-10.log still contains repeated:

  • setup refresh: failed to spawn ...\codex-windows-sandbox-setup.exe
  • The requested operation requires elevation. (os error 740)

So this still appears unfixed on 0.139.0 in my environment.

iceweasel-oai contributor · 1 month ago

this is now fixed

ferrouswheel · 1 month ago

@iceweasel-oai what version or commit is the fix in? latest I installed (0.139.0) still has the issue.

Fanatic9 · 1 month ago
this is now fixed

this is a lie, on latest version and it still won't let me elevate the sandbox. fresh installed twice and same error.\
changing it directly in the config.toml also doesn't work, if i open codex and hit update it just doesn't work and i have to make it unelevated again.
even opening codex with admin privileges it still doesn't let me
on version 26.616.3309.0/[0.141.0] windows

Fanatic9 · 29 days ago

so is this getting fixed at all ? it's a pretty important feature to have broken for over 4 weeks with now 3 updates and still not fixing the issue, all these people care about is pleasing their mac users whilst we are begging for basic features to work correctly, paying for a sub and still getting treated like trash.

BaseBlank · 29 days ago

Completely uninstall it, then install a brand-new copy of the latest version, v0.141;
I tested it using my usual method, and the bug hasn’t been fixed;
However, after installing the latest version, I can use the latest version of Codex CLI without any issues;
As for this bug, it doesn’t affect normal use in the latest version, v0.141.

This bug hasn’t been fixed at all. But you can use version 0.141 normally.
@Fanatic9

Fanatic9 · 28 days ago
Completely uninstall it, then install a brand-new copy of the latest version, v0.141; I tested it using my usual method, and the bug hasn’t been fixed; However, after installing the latest version, I can use the latest version of Codex CLI without any issues; As for this bug, it doesn’t affect normal use in the latest version, v0.141. This bug hasn’t been fixed at all. But you can use version 0.141 normally. @Fanatic9

Not sure why you are replying about something I didn't ask about and isn't the main point, I can use it just fine but it doesn't mean I can turn a blind to this feature which is important when trying to run things elevated that codex can't access.

BaseBlank · 28 days ago
> Completely uninstall it, then install a brand-new copy of the latest version, v0.141; > I tested it using my usual method, and the bug hasn’t been fixed; > However, after installing the latest version, I can use the latest version of Codex CLI without any issues; > As for this bug, it doesn’t affect normal use in the latest version, v0.141. > This bug hasn’t been fixed at all. But you can use version 0.141 normally. > @Fanatic9 Not sure why you are replying about something I didn't ask about and isn't the main point, I can use it just fine but it doesn't mean I can turn a blind to this feature which is important when trying to run things elevated that codex can't access.

Then you should go submit a new, complete, and technically detailed issue of your own, instead of complaining here on my issue and venting your impotent rage.

PillarsZhang · 17 days ago

I found that CreateProcessAsUserW failed: 2 usually means Windows is trying to launch a path that does not exist. I think the test command should be:

codex -c 'windows.sandbox="elevated"' sandbox cmd /d /c echo CODEX_ELEVATED_OK

Fixing this may help expose the real remaining issue. Maybe my ProcMon debugging process helps: https://github.com/openai/codex/issues/28042#issuecomment-4874514520