Linux can restrict the operations available inside user namespaces. In Codex CLI, a bubblewrap startup warning on Ubuntu 26.04 LTS points to a missing helper or a blocked namespace operation; repairing that dependency restores sandboxed commands.

Codex uses the first bwrap executable on PATH and otherwise falls back to a bundled helper. Ubuntu's packaged AppArmor profile permits the restricted operations bubblewrap needs inside its user namespace while the general restriction remains enabled.

An existing Codex CLI installation and a signed-in session showing the warning are the starting point. Package installation and profile loading need sudo, but no model request is needed. Startup warnings can remain cached in the local background server until it restarts.

Steps to fix the bubblewrap sandbox warning in Codex CLI:

  1. Open the startup warning details with F2 in the affected Codex CLI session.

    A message beginning Codex could not find bubblewrap on PATH identifies a missing executable. A warning about creating a user namespace can remain after the package is installed. Unrelated warnings need their own diagnosis.

  2. Exit the Codex session with Ctrl+C.

    A second Ctrl+C may be needed to close the session.

  3. Locate bwrap on the current shell's search path.
    $ command -v bwrap

    A path such as /usr/bin/bwrap means the shell can find the helper. Blank output means it cannot. When the Ubuntu executable is already present, skip the two package-installation steps.

  4. Refresh the Ubuntu package index if bwrap is missing.
    $ sudo apt update

    A repository or signature error must be resolved before package installation; an incomplete index refresh does not establish that the package is available.

  5. Install Ubuntu's bubblewrap package if the executable is missing.

    This changes system packages for all users. APT's confirmation lists the proposed changes; an unrelated removal proposal needs separate diagnosis before confirmation.

    $ sudo apt install bubblewrap

    APT's warning about its scripting interface is harmless for this interactive command.

  6. Check the installed bubblewrap version. Example output:
    $ bwrap --version
    bubblewrap 0.11.1

    A version confirms that the selected executable runs. A command-not-found or execution error means the installation or PATH still needs repair before changing AppArmor.

  7. Test command execution through the Codex sandbox. Example output:
    $ codex sandbox -- uname -s
    bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted

    A returned Linux means the sandbox already works, so the profile checks and loading step can be skipped. Operation not permitted after installation calls for checking the scoped profile. A different error needs diagnosis rather than the same fix by default.

  8. Locate Ubuntu's packaged bubblewrap AppArmor profile if sandbox execution is denied. Example output:
    $ ls /etc/apparmor.d/bwrap-userns-restrict
    /etc/apparmor.d/bwrap-userns-restrict

    Ubuntu 26.04 supplies this file in the apparmor package. A missing-file error means that prerequisite is not intact; stop here for an AppArmor package repair. The older Ubuntu 24.04 extra-profile recipe is not needed for this release.

  9. Inspect the loaded bubblewrap AppArmor profiles.
    $ sudo cat /sys/kernel/security/apparmor/profiles | grep -E "^(bwrap|unpriv_bwrap) "

    Blank output with no error means neither named profile is loaded. An access error or missing security filesystem does not mean the profiles are absent; it requires checking AppArmor availability. Rows ending in (enforce) mean the profiles are already active. If both are active but sandbox execution still fails, check whether PATH selects a different bwrap installation instead of repeatedly loading the profile.

  10. Load the packaged bubblewrap AppArmor profile when it is not active.

    This permits namespace operations for executables matched by Ubuntu's scoped bubblewrap profiles, including other applications using that helper. It leaves the general restriction enabled. A parser error means the profile was not successfully loaded; preserve the error for diagnosis rather than disabling AppArmor.

    $ sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict
  11. Confirm that both scoped profiles are enforced. Example output:
    $ sudo cat /sys/kernel/security/apparmor/profiles | grep -E "^(bwrap|unpriv_bwrap) "
    unpriv_bwrap (enforce)
    bwrap (enforce)

    The row order can vary. Missing rows or a mode other than enforce means the profile state still needs attention before proceeding.

  12. Confirm that Ubuntu's general user-namespace restriction remains enabled. Example output:
    $ cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns
    1

    1 keeps the general restriction in place. 0 indicates a broader exception already exists, and a missing file indicates a different kernel policy; neither establishes this scoped repair. Do not turn off the restriction to make the sandbox test pass.

  13. Stop the local Codex background server after other chats are idle.

    Stopping the server can interrupt active or queued work in other Codex chats. The next ordinary launch starts it again with current sandbox prerequisites.

    $ codex app-server daemon stop
  14. Launch Codex CLI again from the directory that showed the warning.
    $ codex

    The same directory keeps the comparison meaningful. A folder-trust prompt is a separate permission decision; only a project whose configuration you have reviewed should be trusted.
    Related: How to set project trust in Codex

  15. Check the fresh session for the original bubblewrap or user-namespace warning.

    The repaired session should reach the prompt without either warning. A remaining bubblewrap warning in F2 details means the startup problem is unresolved, even if the package or profile checks passed. An unrelated MCP startup error concerns that integration instead; the final sandbox test still needs to pass.

  16. Exit the relaunched Codex session with Ctrl+C.
  17. Verify that a harmless command succeeds through the enabled Codex sandbox. Example output:
    $ codex sandbox -- uname -s
    Linux

    Linux with no sandbox error confirms command execution through the sandbox. A permission error or nonzero exit leaves the repair incomplete. No sandbox-disable flag or permissions override is needed.

Share this guide