Install Codex on Linux and WSL2
Published Jul 15, 2026 · Checked against the official docs
On Linux, install with `npm install -g @openai/codex` or grab the musl binary from GitHub Releases, then install bubblewrap (`sudo apt install bubblewrap`) so the sandbox works. On Windows, Codex runs the same way inside WSL2, but WSL1 stopped working at CLI 0.115, when the Linux sandbox moved to bwrap. Keep your project in the Linux home directory, not `/mnt/c`, or file operations crawl.
Two verified install paths on Linux: the npm package or the prebuilt binary. Either one needs bubblewrap present for the sandbox to work, so install that in the same sitting.
npm install -g @openai/codex
sudo apt install bubblewrap
codex
That’s the whole thing on Debian or Ubuntu. On Fedora it’s sudo dnf install bubblewrap (sandboxing docs).
Install on native Linux
- Get Codex.
npm install -g @openai/codexis the simplest. If you’d rather skip Node, download the musl tarball from the latest GitHub release:codex-x86_64-unknown-linux-musl.tar.gzfor x86_64 orcodex-aarch64-unknown-linux-musl.tar.gzfor arm64. Extract it, rename the single binary tocodex, and put it on your PATH (README). - Install bubblewrap. Since CLI 0.115 the Linux sandbox is bubblewrap (
bwrap), and Codex uses the firstbwrapit finds on your PATH. Without one it falls back to a bundled helper that still needs unprivileged user namespaces (linux-sandbox README). Runsudo apt install bubblewrap. - Start it. Run
codexin your project directory and sign in.
Running under WSL2
WSL2 takes the exact same path as native Linux: install the CLI, install bubblewrap, run codex (sandboxing docs).
WSL1 is the trap. It worked through CLI 0.114, then 0.115 moved the sandbox to bwrap, and WSL1 can’t create the user namespaces bwrap needs, so Codex now rejects sandboxed shell commands there (PR #17559). If shell commands started failing right after an update, that’s the cause. Move to WSL2:
wsl -l -v # check which version each distro is on
wsl --set-version <distro> 2
Keep your code off /mnt/c
Run Codex against files in your Linux home (~), not the Windows mount at /mnt/c. Every file operation under /mnt/c crosses the Windows/Linux boundary, and that path runs at a small fraction of native speed (microsoft/WSL #4197). Codex reads and writes a lot of files per run, so a repo living on /mnt/c makes everything drag. Clone into ~/projects instead.
If it fails
bwrap: Creating new namespace failedorbwrap: Unknown option --argv0right after upgrading to 0.115 usually means you’re on WSL1, not WSL2 (issue #16076). Switch to WSL2.- Sandbox warnings on Ubuntu 24.04 even with bubblewrap installed: 24.04’s AppArmor blocks the user namespace. Load the restrict profile, then Codex can start the sandbox:
sudo apt install apparmor-profiles apparmor-utils
sudo install -m 0644 /usr/share/apparmor/extra-profiles/bwrap-userns-restrict /etc/apparmor.d/bwrap-userns-restrict
sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict
Ubuntu 25.04 handles this on its own (sandboxing docs).
- Still stuck on sandbox startup? See sandbox error: retry without sandbox?.
Related
- Install Codex on Windows — native is the default on Windows; WSL is for Linux-native tooling.
- sandbox error: retry without sandbox?
- sandbox_mode config
Sources
- Official sandboxing docs — learn.chatgpt.com/docs/sandboxing
- openai/codex README — install commands and Linux binary
- openai/codex — codex-rs/linux-sandbox/README.md (bwrap mechanism)
- openai/codex PR #17559 — reject WSL1 bubblewrap sandboxing (0.115)
- openai/codex issue #16076 — 0.115.0 shell commands fail in WSL
- microsoft/WSL issue #4197 — /mnt filesystem performance