Codex sandbox initialization fails with "bwrap: fchdir to oldroot" under Termux + proot Debian

Open 💬 0 comments Opened Jun 26, 2026 by yidaltd-afk

Environment

  • Codex CLI: codex-cli 0.142.2
  • Codex config:
  • approval_policy = "on-request"
  • sandbox_mode = "workspace-write"
  • Config file: /root/.codex/config.toml
  • Platform:
Linux localhost 6.17.0-PRoot-Distro #1 SMP PREEMPT_DYNAMIC Fri, 10 Oct 2025 00:00:00 +0000 aarch64 GNU/Linux
  • Termux / proot Debian indicators:
/proc/version: Linux version 6.17.0-PRoot-Distro (proot@termux) ...

/proc/self/mountinfo also contains Termux / proot-distro paths such as:

/data/data/com.termux/files/usr
/data/data/com.termux/files/usr/var/lib/proot-distro/containers/debian/...

Steps to Reproduce

Start Codex CLI inside the Termux + proot Debian environment with:

approval_policy = "on-request"
sandbox_mode = "workspace-write"

Then ask Codex to run the minimal sandboxed command:

printf 'sandbox smoke test\n'

Actual Behavior

The command fails before the requested command runs:

bwrap: fchdir to oldroot: No such file or directory

This also happens for simple read-only commands. The failure does not appear to depend on the current project, repository path, network access, or the specific command being executed.

Expected Behavior

A minimal sandboxed command such as:

printf 'sandbox smoke test\n'

should execute successfully inside the Codex sandbox.

With approval_policy = "on-request" and sandbox_mode = "workspace-write", simple read-only commands within the allowed filesystem scope should not fail during sandbox initialization.

Impact

Because sandbox initialization fails before the requested command starts:

  • Read-only review workflows become impractical.
  • Every sandboxed command fails before execution.
  • The issue is reproducible using a minimal smoke test.

Diagnostics Performed

Direct command execution outside the Codex sandbox

printf 'direct smoke test\n'

Result:

direct smoke test

Direct bwrap smoke test outside the Codex sandbox

bwrap --ro-bind / / --proc /proc --dev /dev /bin/printf 'bwrap smoke test\n'

Result:

bwrap smoke test
bwrap_exit=0

bwrap is present:

/usr/bin/bwrap
bubblewrap 0.11.0

Linux namespace checks

unshare --user --map-root-user /bin/printf 'userns smoke test\n'
unshare --mount /bin/printf 'mountns smoke test\n'

Result:

userns smoke test
userns_exit=0
mountns smoke test
mountns_exit=0

seccomp status

grep -E '^(NoNewPrivs|Seccomp|Seccomp_filters):' /proc/self/status

Result:

NoNewPrivs: 1
Seccomp: 2
Seccomp_filters: 2

Codex config

approval_policy = "on-request"
sandbox_mode = "workspace-write"

No Permission Profiles are configured.

Preliminary Findings

  • bwrap itself is available and can run a minimal smoke test successfully outside the Codex sandbox.
  • User and mount namespaces are available in this environment.
  • seccomp is enabled.
  • The failure occurs even for a minimal printf command, before the requested command appears to run.
  • In the tested environment, the error occurs only when commands are executed through the Codex-managed sandbox. Direct command execution and standalone bubblewrap tests succeed.
  • I did not find an existing openai/codex issue matching the exact error string:
bwrap: fchdir to oldroot: No such file or directory

View original on GitHub ↗