Windows sandbox regression in Codex CLI 0.138.0: setup refresh fails with os error 740 / CreateProcessAsUserW failed: 2; 0.132.0 works
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.
16 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
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
0.137.0After opening a new PowerShell session,
where.exe codexresolved to the native standalone path: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:
Observed repeated error:
Codex then reported that the sandbox was failing before command execution:
Then even a single safe read command still hit the same sandbox startup error:
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.0and that rollback to0.132.0restored sandbox execution.This new test confirms that:
windows sandbox: spawn setup refreshfailure still exists in0.137.0;codex.exeis the native install under%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe;No private filesystem paths are included here; local project paths and user profile paths have been redacted or replaced with environment-variable placeholders.
````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.0Install path was the native standalone Windows install, not npm:
The doctor output included a sandbox line that looked configured/healthy, but direct sandbox execution still failed.
Minimal direct sandbox test:
Observed result:
At the same time, Windows showed a system dialog for:
with the localized Windows message equivalent to:
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:
Rollback on the same machine:
codex-cli 0.132.0worksAfter rolling back to
0.132.0on the same new machine:Both sandbox modes passed the same minimal smoke tests:
Then normal file-read tool calls also worked again. This strongly narrows the regression to a post-
0.132.0Windows 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:
PR #23764 removed Windows sandbox resource stamping. That PR removed the
windows-sandbox-rsbuild script, the setup helper manifest, thewinresdependency, 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 minimalrequestedExecutionLevel level="asInvoker"manifest so setup refresh can use normalCommand::new(...)without triggering UAC, while full setup can still intentionally useShellExecuteExWwithrunas.The new
0.137.0native-install failure shown above is not the same as onlyos error 740. It isCreateProcessAsUserW failed: 2plus a Windows dialog sayingcodex-windows-sandbox-setup.execannot 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 containingcodex.exebut missingcodex-windows-sandbox-setup.exeandcodex-command-runner.exe.The important new signal is that
0.137.0still fails on a brand-new machine with the native standalone install, while0.132.0works immediately on the same machine and same install path. That suggests the manifest restoration in #25949 may have fixed theos error 740variant, but it does not fully cover the helper-location / helper-packaging / setup-refresh path that producesCreateProcessAsUserW failed: 2and “cannot find codex-windows-sandbox-setup.exe”.Requested diagnostic improvement
codex doctorshould probably verify the actual sandbox helper resolution path by checking that the exact runtime directory used by sandbox setup contains at least: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.
Same experience.
Windows 11 Pro 10.0.26200
Codex 0.138.0 npm install
Same machine, same command works on 0.132.0:
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
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/.sandboxlogs show repeatedsetup refresh: failed to spawn ...codex-windows-sandbox-setup.exe: ... (os error 740)in elevated mode.Repro in thread was
rg --filesand simple PowerShell commands inside Codex, while direct execution outside Codex succeeds.CLI at repro:
0.137.0, and sandbox mode configured as elevated.@martinmclee
https://github.com/openai/codex/issues/24391#issuecomment-4657143980
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 errorcodex --version(run in-thread) -> same error~/.codex/.sandbox/sandbox.2026-06-10.logstill contains repeated:setup refresh: failed to spawn ...\codex-windows-sandbox-setup.exeThe requested operation requires elevation. (os error 740)So this still appears unfixed on 0.139.0 in my environment.
this is now fixed
@iceweasel-oai what version or commit is the fix in? latest I installed (0.139.0) still has the issue.
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
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.
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.
I found that
CreateProcessAsUserW failed: 2usually means Windows is trying to launch a path that does not exist. I think the test command should be:Fixing this may help expose the real remaining issue. Maybe my ProcMon debugging process helps: https://github.com/openai/codex/issues/28042#issuecomment-4874514520