Sandbox fails with "bwrap: execvp /bin/bash: No such file or directory" on Ubuntu 24.04
Status Closed — not planned
Reported on v2.1.89
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 8 comments · opened Apr 1, 2026 · closed Jun 4, 2026
Bug Description
All Bash tool calls fail when sandbox is enabled, with the error:
bwrap: execvp /bin/bash: No such file or directory
Environment
- Claude Code: 2.1.89
- OS: Ubuntu 24.04.4 LTS (Noble Numbat)
- Kernel: 6.8.0-106-generic x86_64
- bubblewrap: 0.9.0
- bash:
/bin/bashexists, ELF 64-bit LSB pie executable
Sandbox config (settings.json)
"sandbox": {
"enabled": true,
"filesystem": {
"denyRead": ["/"],
"allowRead": [".", "~/.claude", "$TMPDIR", "/tmp/build", "~/go/pkg/mod", "/usr", "/lib", "/lib64", "/etc", "/bin", "/sbin", "/proc", "/dev"]
}
}
Reproduction
- Enable sandbox with the config above on Ubuntu 24.04 with bubblewrap 0.9.0
- Any Bash tool call fails with
bwrap: execvp /bin/bash: No such file or directory
Observations
/bin/bashexists and is a valid binary (file /bin/bash→ ELF 64-bit LSB pie executable)- Running
bwrapmanually with--ro-bind /bin /binworks fine:bwrap --ro-bind /bin /bin --ro-bind /usr /usr --ro-bind /lib /lib --ro-bind /lib64 /lib64 --proc /proc --dev /dev /bin/bash -c "echo works"→ success - Disabling sandbox (
"enabled": false) or usingdangerouslyDisableSandbox: trueworks around the issue
Workaround
Disable sandbox in settings or approve dangerouslyDisableSandbox per command.
8 Comments
So frustrated with lack of support on claude app code I'll join anything. 🙂
I’m running into the same issue when trying to restrict Claude Code so it can only read from certain directories in this way. I don’t think simply disabling the sandbox is the right solution, since that defeats the purpose of the restriction. Are there any updates on this issue, or has anyone found a workaround for implementing this properly?
same issue! although i use zsh.
@claude
The issue occurs on systems using a merged /usr layout (e.g. Ubuntu 24.04+), where /bin, /lib, /lib64, and /sbin are symlinks pointing to their /usr counterparts:
/bin -> usr/bin/lib -> usr/lib/lib64 -> usr/lib64/sbin -> usr/sbinClaude Code builds the sandbox in two steps:
--ro-bind / /--tmpfs /usr--tmpfs /bin--tmpfs /lib64The problem is that --tmpfs /usr wipes out /usr/bin, /usr/lib, etc. inside the sandbox. Since /bin is a symlink to usr/bin, it now points to an empty directory. When bwrap then tries to execute /bin/bash inside the sandbox, it fails with:
bwrap: execvp /bin/bash: No such file or directoryClaude Code assumes these paths are real directories that can be independently overlaid. This assumption breaks on merged /usr systems - wiping /usr silently breaks all of them.
The fix should be on Claude Code's side: before issuing --tmpfs for a path, check whether it is a symlink or whether any top-level symlinks resolve through it, and handle those cases accordingly.
Workaround which worked for me but I don't recommend: intercept bwrap calls using a wrapper script placed at /usr/bin/bwrap (with the original binary moved aside). The wrapper inspects each argument before passing it to the real bwrap, and skips --tmpfs for paths that are symlinks or known merged-/usr paths (/usr, /bin, /lib, /lib64, /sbin and their .usr-is-merged variants). This prevents Claude Code from wiping out directories that are critical for bash to run inside the sandbox. This is not an ideal solution as it may cause issues when updating bwrap via apt.
Same root cause on CachyOS (Arch,
/usr-merged) with Claude Code 2.1.119 and bubblewrap 0.11.2. The surface is just a bit earlier than the OP: failure at mount setup, notexecvp:bwrap argv (captured via wrapper) shows
--tmpfs /usrrunning before--tmpfs /bin. Once/usris wiped,/bin(symlink →/usr/bin) has no target, so bwrap can't even create the mount point.Only workaround is disabling the sandbox. A fix that skips
--tmpfsfor symlinked paths (or detects merged-/usr) would cover such distros.Reproduced the exact same error on Fedora 43, trying to setup sandboxing for Claude code. Disabled sandboxing for now.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
wtf closed by bot?