[BUG] Git Bash on Windows: piped commands hang, stdout never captured

Resolved 💬 3 comments Opened Apr 25, 2026 by icepicck Closed Apr 28, 2026

Summary

On Windows 11 / Git Bash, Bash tool calls that pipe a short-lived command into another (e.g. node script.js 2>&1 | tail -60) are surfaced as background tasks but stdout never reaches the task output file. The file stays at 0 bytes indefinitely even though the underlying process runs to completion. TaskOutput blocks until timeout and reports running forever. Stuck task IDs accumulate across the session.

Appears to share root cause with several prior issues, but with a different failure shape — instead of immediate exit 1 / Bad file descriptor with empty output, the call hangs and is displayed as a background task that never completes.

Environment

  • Claude Code CLI (Opus 4.7) on Windows 11 Home (10.0.26200)
  • Shell: Git Bash (MSYSTEM=MINGW64), bash --version: 5.3.9
  • CLAUDE_CODE_SHELL is unset; CC is correctly defaulting to Git Bash (/usr/bin/bash resolves into MINGW64, not WSL bash). So this is not the WSL-bash-picked-by-accident failure mode from #26430.

Repro

node tests/run-state-tests.js 2>&1 | tail -60
  • Expected: ~10s runtime, prints test summary, exits 0.
  • Actual: tool returns "Command running in background with ID …", output file stays empty, TaskOutput blocks 30s+ and reports running even after the underlying process has exited.

Working workaround

Redirect inside the command and read the log file directly:

node tests/run-state-tests.js > /tmp/state-test-out.log 2>&1; echo "EXIT=$?"

Output appears as expected. Bug is specifically in how Bash-tool stdout is captured when a piped command is promoted to a background task.

Impact

  • Forces a redirect-and-poll workaround on every test/build invocation that pipes
  • Multiple stuck task IDs accumulate per session
  • Breaks the standard "run tests, parse output" agent loop

Frequency

Every invocation of a piped short command in affected sessions. Reproducible.

Prior art

Currently open:

  • #31449 — VS Code extension: Bash tool does not capture stdout. Related, but affects the VSCode extension specifically. This report is for the CLI on Windows, where the failure shape is different (hang as background task vs. popup terminal window).

Closed without fix:

  • #21915 — original "Bash tool produces no output on Windows"
  • #26430 — closed NOT_PLANNED for inactivity. Comments document the same root cause and note that npm install -g @anthropic-ai/claude-code fixed it for at least one user where the native installer / winget binary did not.
  • #25558 — CLAUDE_CODE_SHELL environment variable ignored on Windows; closed NOT_PLANNED
  • #36915 — auto-closed as duplicate of #31449
  • #20236 — TaskOutput hangs after task completes

Closed as completed (different failure shape):

  • #26413 — Bash tool: all commands fail with Bad file descriptor on Windows; closed COMPLETED. The fix shipped for the immediate-failure case, but the regression reported here (hang as a background task that never completes) was not covered.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗