Unified exec broken on linux since 0.57.0

Resolved 💬 6 comments Opened Nov 10, 2025 by Szpadel Closed Nov 12, 2025
💡 Likely answer: A maintainer (jif-oai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.57.0

What subscription do you have?

Pro

Which model were you using?

any

What platform is your computer?

Linux 6.17.5-cachyos1.lto.fc43.x86_64 x86_64 unknown

What issue are you seeing?

When feature.unified_exec is enabled all execution commands fail (since alpha.5 I believe) with

error: unexpected argument '--sandbox-policy-cwd' found

What steps can reproduce the bug?

set feature.unified_exec to true
ask model to run any command

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

6 Comments

jif-oai contributor · 9 months ago

Do you have any reference to codex-linux-sandbox in your PATH? Or multiple installation of codex?

Szpadel · 9 months ago

No, it's reproducible with simple bunx @openai/codex without any other codex installation in the PATH

pakrym-oai contributor · 9 months ago

This should be fixed in the latest alpha.

de-tre · 4 months ago

I can still reproduce this on WSL2 with a current setup, and for me it appears to be the same underlying failure mode.

Environment:

  • WSL2
  • Codex CLI: 0.122.0
  • bundled VS Code Codex binary: 0.122.0-alpha.13
  • bubblewrap 0.11.1
  • bwrap --help includes --argv0

Without legacy landlock, even a minimal sandbox smoke test fails:

codex sandbox linux --full-auto -- /bin/true

with:

WARNING: proceeding, even though we could not update PATH: Read-only file system (os error 30)
error: unexpected argument '--sandbox-policy-cwd' found

  tip: a similar argument exists: '--sandbox'

Usage: codex [OPTIONS] [PROMPT]
       codex [OPTIONS] <COMMAND> [ARGS]

With legacy landlock enabled, the equivalent minimal test succeeds:

codex -c 'features.use_legacy_landlock=true' sandbox linux --full-auto -- /bin/true

I also checked the generated helper shim directly, and it does support the flag:

latest="$(find ~/.codex/tmp/arg0 -maxdepth 1 -mindepth 1 -type d -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2-)"
"$latest/codex-linux-sandbox" --help

which shows:

Usage: codex-linux-sandbox [OPTIONS] --sandbox-policy-cwd <SANDBOX_POLICY_CWD> [COMMAND]...

So this does not look like the older bwrap --argv0 issue. It looks more like the non-legacy Linux sandbox re-exec path is landing in the normal codex CLI parser instead of the sandbox-helper mode, causing --sandbox-policy-cwd to be rejected.

Current workaround for me is:

[features]
use_legacy_landlock = true

That restores normal sandbox behavior, but it now emits a deprecation warning.

maru-k-lab · 3 months ago

I can reproduce a closely related failure on Linux with Codex CLI 0.132.0 / 0.133.0.

It looks like --sandbox-policy-cwd itself is not a public CLI option. It is accepted only when the native Codex binary
is invoked with argv[0] == "codex-linux-sandbox".

This matches the linux-sandbox README:
https://github.com/openai/codex/blob/main/codex-rs/linux-sandbox/README.md

What I observed:

```bash
# Works: native binary sees argv0=codex-linux-sandbox and enters linux sandbox helper mode
bash -lc 'exec -a codex-linux-sandbox /path/to/native/codex --help'

# Fails: npm wrapper does not propagate argv0 to the native binary
bash -lc 'exec -a codex-linux-sandbox /path/to/npm/bin/codex --sandbox-policy-cwd /tmp -- /bin/true'
# error: unexpected argument '--sandbox-policy-cwd' found

In my current session, sandboxed tool execution is launched roughly as:

bwrap ... --argv0 codex-linux-sandbox -- /home/user/.local/bin/codex --sandbox-policy-cwd ... --command-cwd ...
--permission-profile ...

So if /home/user/.local/bin/codex points to the native binary, unified exec works. If it points to the npm wrapper, the
helper argv0 is lost and the command is parsed by the public CLI, causing the unexpected argument error.

This suggests the failure mode is not that --sandbox-policy-cwd was removed, but that the npm wrapper path does not
preserve argv0=codex-linux-sandbox when re-execing the native binary.

A possible fix would be for bin/codex.js to pass argv0: process.argv0 (or otherwise preserve the helper argv0) when
spawning the native binary.

maru-k-lab · 2 months ago

Follow-up from my side: this is now resolved in my environment with Codex CLI 0.137.0.

I was previously able to reproduce a closely related failure on Linux with Codex CLI 0.132.0 / 0.133.0.

My current understanding is that --sandbox-policy-cwd is not a public CLI option. It is accepted only when the native Codex binary is invoked with argv[0] == "codex-linux-sandbox".

This matches the linux-sandbox README:
https://github.com/openai/codex/blob/main/codex-rs/linux-sandbox/README.md

What I observed:

# Works: native binary sees argv0=codex-linux-sandbox and enters linux sandbox helper mode
bash -lc 'exec -a codex-linux-sandbox /path/to/native/codex --help'

# Fails: npm wrapper does not propagate argv0 to the native binary
bash -lc 'exec -a codex-linux-sandbox /path/to/npm/bin/codex --sandbox-policy-cwd /tmp -- /bin/true'
# error: unexpected argument '--sandbox-policy-cwd' found

In my previous failing setup, sandboxed tool execution was launched roughly as:

bwrap ... --argv0 codex-linux-sandbox -- /home/user/.local/bin/codex --sandbox-policy-cwd ... --command-cwd ... --permission-profile ...

So if /home/user/.local/bin/codex points to the native binary, unified exec works. If it points to the npm wrapper, the helper argv0 is lost and the command is parsed by the public CLI, causing the unexpected argument error.

This suggests the failure mode was not that --sandbox-policy-cwd had been removed, but that the npm wrapper path did not preserve argv0=codex-linux-sandbox when re-execing the native binary.

A possible fix, if this path is still relevant, would be for bin/codex.js to preserve the helper argv0 when spawning the native binary, for example by passing argv0: process.argv0 or an equivalent mechanism.

With 0.137.0, I confirmed that direct execution, PATH-based execution, and the Claude Code /codex bridge smoke test all work in my environment, so I consider my issue closed.