Bash tool broken on Windows: Git Bash MSYS2 Bad file descriptor with piped stdout

Resolved 💬 7 comments Opened Feb 18, 2026 by Daniel-Cherny Closed Feb 19, 2026

Description

The Bash tool fails on every command with exit code 1 and no output on Windows. Even echo hello fails silently.

Environment

  • Claude Code: 2.1.45
  • OS: Windows 11 Home 24H2 (Build 26100.7623)
  • Git for Windows: 2.51.0
  • Git Bash (MSYS2): C:\Program Files\Git\usr\bin\bash.exe
  • Node: 22.17.0

Root Cause

Git Bash (MSYS2 runtime) produces Bad file descriptor when stdout is a pipe rather than a console. Claude Code's Bash tool captures output via pipes, so MSYS2 can't write to them.

The actual error (visible when stderr is captured via PowerShell wrapper):

/usr/bin/bash: line 1: echo: write error: Bad file descriptor

Reproduction Steps

  1. Install Git for Windows 2.51.0 on Windows 11
  2. Open Claude Code 2.1.45
  3. Run any Bash tool command, e.g. echo hello
  4. Result: Exit code 1, zero output

Key Observations

| Method | Result |
|--------|--------|
| Bash tool directly | BROKEN - exit code 1, no output |
| powershell.exe -NoProfile -Command "echo hello" via Bash tool | Works |
| WSL bash (C:\Windows\System32\bash.exe) via Bash tool | Works |
| Git Bash from user's PowerShell terminal | Works (ConPTY gives it a real console, not a pipe) |
| Session hooks (e.g. tdd-guard) | Works (different I/O path - exit code check, not piped stdout) |

This confirms the issue is specifically with how Claude Code creates stdout/stderr pipes for the Bash tool, and MSYS2's inability to write to those pipes.

Workaround

Wrapping all commands in PowerShell works:

powershell.exe -NoProfile -Command "git status"

Expected Behavior

echo hello should print hello and exit with code 0.

Additional Context

  • The dangerouslyDisableSandbox: true option does not fix this (also tested).
  • Git Bash with --login flag also fails with the same error.
  • This may be a regression in Claude Code 2.1.45's pipe handling, a regression in Git for Windows 2.51.0's MSYS2 runtime, or an interaction between the two.

View original on GitHub ↗

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