[Bug] Bash commands exit with code 1 on Windows due to file descriptor incompatibility with Git Bash
Bug Description
Bug: Bash commands fail with exit code 1 on Windows due to file descriptor stdio incompatibility with Git Bash
Environment:
Claude Code v2.1.45 (both npm and native installs affected)
Windows 10 Pro
Git for Windows 2.43.0 (bash.exe at C:\Program Files\Git\bin\bash.exe)
Node.js installed via standard path
Problem:
Every Bash tool command fails with exit code 1 and zero output (no stdout, no stderr) on Windows. Even echo hello fails. The debug log shows "Session environment not yet supported on Windows" followed by "Shell command failed" for every command.
Root Cause:
In the nw1 function in cli.js, the spawn call passes a file descriptor for stdout/stderr:
let v = CA9(V.path, "a");
spawn(shellPath, args, { stdio: ["pipe", v, v], ... });
Git Bash (MSYS2) on Windows cannot write to a Windows file descriptor passed this way. The bash process silently exits with code 1 and produces no output. This does not affect PowerShell commands (which is why powershell -Command "echo hello" worked through the Bash tool).
Proof:
spawn(bash, ["-c", "-l", "echo hello"], { stdio: ["pipe", "pipe", "pipe"] }) → exit 0, output "hello" ✅
spawn(bash, ["-c", "-l", "echo hello"], { stdio: ["pipe", fileFd, fileFd] }) → exit 1, empty output ❌
Fix (verified working):
On Windows, use pipe-based stdio instead of file-descriptor stdio, and set stdoutToFile=false so output is read from the in-memory buffer populated by the existing VO8 pipe listeners:
// In nw1 function, replace the spawn block with:
if (a8() === "windows") {
V.stdoutToFile = false;
T = spawn(W, G, { ...opts, stdio: ["pipe", "pipe", "pipe"] });
closeSync(v);
} else {
T = spawn(W, G, { ...opts, stdio: ["pipe", v, v] });
closeSync(v);
}
This is a two-line change that only affects Windows and fixes all bash execution. Tested with simple commands, piping, loops, stderr capture, and multi-line output — all pass.
Environment Info
- Platform: win32
- Terminal: windows-terminal
- Version: 2.1.45
- Feedback ID: 6aae184f-1917-4f45-965e-5325e4375c00
Errors
[{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at w06 (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1877:29990)","timestamp":"2026-02-18T11:05:55.492Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at w06 (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1877:29990)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async M (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3735:17800)","timestamp":"2026-02-18T11:05:56.067Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at w06 (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1877:29990)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async P (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3735:18316)","timestamp":"2026-02-18T11:05:56.068Z"},{"error":"Error: LSP server plugin:csharp-lsp:csharp-ls failed to start: spawn csharp-ls ENOENT\n at Object.start (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2392:22369)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Object.H [as start] (file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2392:24805)","timestamp":"2026-02-18T11:05:56.193Z"},{"error":"Error: spawn csharp-ls ENOENT\n at ChildProcess._handle.onexit (node:internal/child_process:286:19)\n at onErrorNT (node:internal/child_process:484:16)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","timestamp":"2026-02-18T11:05:56.193Z"},{"error":"Error: Failed to start LSP server plugin:csharp-lsp:csharp-ls: spawn csharp-ls ENOENT\n at file:///C:/Users/Adamk/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2392:32664\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2026-02-18T11:05:56.193Z"}]This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗