claude-code - 💡(How to fix) Fix Bash sandbox (bwrap) fails when .git/hooks is a symlink on Linux

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

bwrap: Can't create file at /path/to/repo/.git/hooks: No such file or directory

Root Cause

bwrap walks the current directory tree to set up bind-mount points in a tmpfs overlay. When it hits .git/hooks as a symlink, it cannot create a real directory at that path in the tmpfs, causing the entire sandbox setup to fail. The path resolves correctly in userspace (os.path.exists returns True) — the issue is specific to bwrap's virtual filesystem construction.

Fix Action

Workaround

Use dangerouslyDisableSandbox: true on affected bash commands.

Code Example

bwrap: Can't create file at /path/to/repo/.git/hooks: No such file or directory

---

mkdir testrepo && cd testrepo && git init
mkdir tracked-hooks
rm -rf .git/hooks
ln -s ../tracked-hooks .git/hooks
# Now run any bash command in Claude Code on Linux (default sandbox mode)
RAW_BUFFERClick to expand / collapse

On Linux, any bash command fails with a misleading error when the repo's .git/hooks is a symlink to a real directory rather than a plain directory. This is a common setup for sharing hooks via version control.

Error

bwrap: Can't create file at /path/to/repo/.git/hooks: No such file or directory

Steps to Reproduce

mkdir testrepo && cd testrepo && git init
mkdir tracked-hooks
rm -rf .git/hooks
ln -s ../tracked-hooks .git/hooks
# Now run any bash command in Claude Code on Linux (default sandbox mode)

Expected Behavior

The bash command runs successfully inside the sandbox.

Actual Behavior

bwrap fails to construct the sandbox and the command errors out with the message above.

Root Cause

bwrap walks the current directory tree to set up bind-mount points in a tmpfs overlay. When it hits .git/hooks as a symlink, it cannot create a real directory at that path in the tmpfs, causing the entire sandbox setup to fail. The path resolves correctly in userspace (os.path.exists returns True) — the issue is specific to bwrap's virtual filesystem construction.

Workaround

Use dangerouslyDisableSandbox: true on affected bash commands.

Platform

Linux only. macOS uses a different sandbox mechanism that is not affected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Bash sandbox (bwrap) fails when .git/hooks is a symlink on Linux