Claude Code Bash tool hits E2BIG when sandbox profiles scale with large git worktrees
jkMLnop · ghdev · 2026-07-17
A Claude Code bug report shows Bash tool calls failing with spawn E2BIG whenever the working directory is inside a non-trivial git repository.
Main finding
The command itself is not the problem. The compiled sandbox filesystem policy grows with the repository's working-tree file count until the OS argument-length limit is exceeded. The report says the error mentions around 187 filesystem deny paths and a compiled profile around 1–1.1 MB.
Repro pattern
The failure appears to require both of these conditions:
- cwd is inside a git repo
- the repo has a sufficiently large working tree
Observed behavior:
- non-git directories did not fail, even with 377,000+ files
- a git repo with one file worked
- git repos with 148+ working-tree files consistently failed, up to roughly 40,000 files
What was ruled out
The reporter says they tested and eliminated several plausible causes, including:
- git internals / reflog file count
- .claude/commands
- per-project Claude Code session history
- secret-filename pattern matching
The report concludes that the pattern is robust, but the exact internal code path still needs source access to identify.
More from coding & agent
- 250 Builders Hack With Codex at Berlin Community Hackathon Ahead of OpenAI DevDay — paw_lean · 2026-10-26
- Building AI bots on raw APIs? Devs say models are 'dumb without the harness' — madeofAjala · 2026-10-26
- HarnessMM cuts agent tokens per task by up to 88% while raising success rates — omarsar0 · 2026-10-26
- Microsoft demos intent-classifying agents built with Copilot App and Foundry, deployable across Teams and Outlook — marlene_zw · 2026-10-26
- Looking for a wearable mic with best battery life that feeds recordings to personal agents via MCP — altryne · 2026-10-26
- The identity crisis in software engineering: multiagent systems demand a new problem set — rakyll · 2026-10-26