Windows: Bash tool permanently broken in long-lived sessions - inlined shell snapshot exceeds command-line length and is truncated

Status Open
Reported on v2.1.233
Maintainer reply None cached
Activity 0 comments · opened Aug 20, 2026

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 "<string>" 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 <file> (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".

View original on GitHub ↗