anthropics / anthropics/claude-code
Windows: Bash tool permanently broken in long-lived sessions - inlined shell snapshot exceeds command-line length and is truncated
- Vorherrschende Sprache
- Python
- Sterne
- 145k
- Forks
- 23.1k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
# Bug report — para /bug o github.com/anthropics/claude-code/issues
**Title:** Windows: Bash tool permanently broken in long-lived sessions — inlined shell snapshot + wrapper exceeds command-line length and is truncated (every command fails with "unexpected EOF")
**Environment:** Claude Code 2.1.233 (VS Code extension), Windows 11 Home 10.0.26200, Git Bash (msys), ~17 plugins enabled, session resumed multiple times over several days.
**Symptom:** Every Bash tool call fails, including `true` and `pwd`. Errors rotate between:
```
/usr/bin/bash: -c: line 67: unexpected EOF while looking for matching `''
/usr/bin/bash: line 67: /dev/n: No such file or directory
/usr/bin/bash: line 67: p: command not found
```
The visible fragment shows the harness wrapper truncated mid-token (e.g. `eval 'git status' < /dev/null && pwd -P >| '` — the cwd-file path is cut off). The cut point moves 1:1 with the length of the user command, indicating a fixed total-length cap on the composed `bash -c` string.
**Root cause (diagnosed):**
1. The Bash tool composes ONE `bash -c ""` that INLINES the shell snapshot (~45 lines; on this machine the `export PATH` line alone is ~4.5KB due to duplicated Windows PATH blocks + one `bin` dir per enabled plugin) plus the harness prologue/epilogue. Error line numbers (64-71) match snapshot lines + wrapper lines.
2. When the environment grows (plugins loaded at resume, duplicated PATH), the composed string crosses a Windows command-line length limit and is silently truncated → unparseable script → every call fails.
3. The composed wrapper appears to be CACHED per conversation: editing/shrinking the files in `~/.claude/shell-snapshots/` mid-session has no effect (error stays at the same line even after replacing the active snapshot with a 3-line file). Only a brand-new conversation regenerates it.
4. Subagents spawned by the broken session inherit the same broken wrapper; retries never help (deterministic).
**Repro sketch:** Windows + many plugins + duplicated PATH (launch VS Code from an already-extended shell) → long-lived conversation with several resumes → Bash calls degrade from "long commands fail" to "everything fails".
**Suggested fix:** write the composed script to a temp file and execute `bash ` (or source the snapshot by path) instead of inlining everything into `-c` — removes the length ceiling entirely. Related: #55671 (command line too long on Windows), #31437 (snapshot inlining overhead).
**Impact:** total loss of shell for the session (file tools keep working); user-visible as "Claude can't run any command anymore".
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start at the Bash tool entry point that constructs the Windows `bash -c` wrapper, and inspect the files under `~/.claude/shell-snapshots/` involved in the cached snapshot. Reproduce with a long PATH and multiple plugins, then verify that executing the composed script from a temporary file avoids truncation and that short commands such as `true` and `pwd` succeed in a resumed session.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- bash, python
- Bereich
- cli, operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100