excludedCommands in sandbox config does not bypass bwrap filesystem restrictions

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened Feb 25, 2026 · closed Feb 25, 2026

Description

excludedCommands: ["git"] in settings.json sandbox config does not bypass bwrap filesystem write restrictions. Git commands that need to write (e.g., git add, git commit) fail with "Read-only file system" when the repo is outside the sandbox's writable paths.

Environment

  • Claude Code v2.1.56
  • bwrap 0.9.0
  • Ubuntu 24.04 (WSL2)
  • Settings: sandbox.enabled: true, sandbox.excludedCommands: ["git"]

Steps to Reproduce

  1. Configure settings.json with:
{
  "sandbox": {
    "enabled": true,
    "excludedCommands": ["git"]
  }
}
  1. Set CWD to /home/user (writable by sandbox)
  2. Have a git repo at /opt/project (outside sandbox write allowlist)
  3. Run: git -C /opt/project add file.txt

Expected Behavior

git should run outside the bwrap sandbox (per excludedCommands docs), allowing writes to /opt/project/.git/.

Actual Behavior

fatal: Unable to create '/opt/project/.git/index.lock': Read-only file system

Even git via a shell script at a writable temp path fails — the sandbox applies filesystem restrictions regardless of excludedCommands.

Workaround

User must run git commands manually outside Claude Code, or via a script in a separate terminal.

Notes

  • Read-only git commands (git status, git log, git diff) work fine since they don't write to .git/
  • The excludedCommands setting appears to have no observable effect on bwrap mount behavior

View original on GitHub ↗

3 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/17821
  2. https://github.com/anthropics/claude-code/issues/10524
  3. https://github.com/anthropics/claude-code/issues/22620

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Master-Rensei · 7 months ago

Closing as duplicate of #17727 — the root cause is the same: bwrap on Linux doesn't properly handle excludedCommands or filesystem write permissions. Upvoted the original.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.