Bash tool fails with exit code 1 on Windows - stdout capture broken
Open 💬 7 comments Opened Feb 18, 2026 by enyakucera
Description
All Bash tool commands that produce stdout output fail with exit code 1 on Windows. Commands that produce no output (like true) succeed. Writing to files works correctly.
Environment
- Claude Code version: 2.1.45
- OS: Windows 11 Pro for Workstations (10.0.26100)
- Shell: Git Bash (MINGW64), GNU bash 5.2.37(1)-release (x86_64-pc-msys)
- Platform: MINGW64_NT-10.0-26100, x86_64
Steps to Reproduce
- Launch Claude Code on Windows with Git Bash
- Ask Claude to run any command that produces stdout output
Observed Behavior
| Command | Result |
|---------|--------|
| true | exit 0 ✅ |
| echo "test" | exit 1 ❌ |
| pwd | exit 1 ❌ |
| ls | exit 1 ❌ |
| builtin echo "test" | exit 1 ❌ |
| echo "test" > /tmp/file.txt 2>&1; true | exit 0 ✅ (file contains "test") |
Terminal shows: /usr/bin/echo: /usr/bin/echo: cannot execute binary file
Diagnostics
/usr/bin/echo.exeis a valid Windows binary:PE32+ executable for MS Windows 5.02 (console), x86-64/usr/bin/ls.exeis also a valid PE32+ executable- Bash builtins work when output is redirected to a file
- The issue appears to be with stdout capture by Claude Code, not with the binaries themselves
MSYSTEM=MINGW64,TERM=xterm-256color
What I've Tried
- Setting
$env:SHELLto various Git Bash paths (C:\Program Files\Git\bin\bash.exe,C:\Program Files\Git\usr\bin\bash.exe) - Deleting
~/.claude/shell-snapshots/ - Reinstalling Git for Windows
- Updating Claude Code to latest version (2.1.45)
- Running from different terminals (PowerShell, CMD, Git Bash)
- Setting
$env:SHELL = "powershell"(Claude Code still uses bash)
Expected Behavior
Bash commands should execute and their stdout output should be captured and returned to the agent.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗