anthropics / anthropics/claude-code

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

オープン
#88,311 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:bash bug has repro platform:vscode platform:windows
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

# 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".

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
bash, python
領域
cli, operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。