[BUG] Bash tool returns exit 1 with no output for all commands on Windows/MINGW (set -o onecmd injection)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment:
- Claude Code version: v2.1.45 (native installer)
- Platform: Windows 10/11, MINGW64 (Git Bash)
- Shell: bash via MINGW64_NT-10.0-26200
Symptoms:
- Every Bash tool call returns exit code 1 with empty output
- Affects all commands including echo "hello", pwd, git status
- Intermittent — works in some sessions, broken in others within the same day
- When broken, persists for the entire session (no recovery)
Root cause (diagnosed):
- Claude Code's shell snapshot mechanism injects set -o onecmd into $SHELLOPTS
- onecmd causes bash to exit after executing one command, which the tool interprets as failure
- Confirmed by comparing $SHELLOPTS in Claude Code (has onecmd) vs Codex in same environment (no onecmd)
Impact:
- All git operations, builds, typechecks, and terminal commands fail
- Skill auto-run commands (backtick blocks) abort entire skill load on first non-zero exit
- Led to ~1 hour of misdiagnosed "Windows/MINGW incompatibility" debugging, producing incorrect workarounds committed to codebase
- Workaround changes to /smart-commit skill were unnecessary — the commands were fine, the shell was broken
Related: #19057 (may be same issue — v2.1.30 changelog claimed a fix but it doesn't work on v2.1.45)
Repro:
- Open Claude Code on Windows/MINGW
- Run any Bash command: echo "hello"
- Observe exit code 1, no output
What Should Happen?
Bash tool commands should execute normally and return their actual exit code and output. echo "hello" should return exit 0 with "hello" as output. pwd should return the current directory. All standard bash commands should work regardless of Claude Code's internal shell state snapshotting.
Error Messages/Logs
Every Bash tool call returns exit code 1 with empty output:
> echo "hello"
Exit code 1
(no output)
> pwd
Exit code 1
(no output)
> git status
Exit code 1
(no output)
Diagnosed root cause: $SHELLOPTS contains "onecmd" which is injected by Claude Code's shell snapshot mechanism. Comparing same environment:
Claude Code $SHELLOPTS: braceexpand:hashall:interactive-comments:onecmd
Codex $SHELLOPTS: braceexpand:hashall:interactive-comments
The "onecmd" option causes bash to exit after a single command, which the Bash tool interprets as failure.
Bug is intermittent across sessions — some sessions work, others are broken from the start with no recovery. When broken, ALL commands fail for the entire session.
Platform: Windows 10/11, MINGW64_NT-10.0-26200 3.6.4, Claude Code v2.1.45 (native installer)
Steps to Reproduce
- Install Claude Code v2.1.45 via native Windows installer (not npm)
- Open Claude Code in a Git Bash / MINGW64 terminal on Windows
- Start a new conversation
- Ask Claude to run any Bash command, e.g.: "run echo hello"
- Observe: exit code 1, no output
Diagnosis step (run in a separate terminal, not through Claude Code):
echo $SHELLOPTS
# Expected: braceexpand:hashall:interactive-comments
# Actual (when bug is active): braceexpand:hashall:interactive-comments:onecmd
Key observations:
- Bug is session-level: if the first command fails, ALL commands fail for that session
- Starting a new conversation sometimes fixes it (new shell snapshot)
- The same terminal/environment works perfectly with Codex CLI
- No .bashrc or .bash_profile changes affect it — the onecmd injection happens inside Claude Code's shell snapshot mechanism
- Workarounds like renaming .bashrc, clearing BASH_ENV, and clearing snapshot cache do NOT fix it
- This is NOT a Windows/MINGW limitation — the same commands work in the same shell outside Claude Code
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.45
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
## System Details
- Terminal: Git Bash (MINGW64) — the default shell for Claude Code native Windows install
- OS: Windows 10, MINGW64_NT-10.0-26200 3.6.4-b9f03e96.x86_64
- Claude Code: v2.1.45 (native installer, not npm)
- Node: installed via pnpm
- Shell: /usr/bin/bash (MSYS2/MINGW64 bash)
Note: Git Bash is not listed in the terminal dropdown, but it's the shell
Claude Code defaults to on Windows native installs.
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Updated diagnosis: stdout capture failure, not just onecmd
Environment: Windows 11, MINGW64, Claude Code v2.1.45 (native installer)
After deeper testing, the original characterization ("all commands fail") is inaccurate. The actual bug is more nuanced:
What actually happens
Builtins with stdout → FAIL (exit 1, no output):
Builtins with redirected/no stdout → WORK:
External commands → WORK:
Mixed chains:
Key findings
works.
onecmd re-injected. Old snapshots are not reused.
Snapshot behavior
~/.claude/shell-snapshots/ contains per-session snapshots. New sessions always create a new file rather than reusing existing ones. The snapshot capture logic erroneously includes set -o
onecmd in every captured state.
Possible regression in v2.1.45
This was working on v2.1.44 (published Feb 16). v2.1.45 (published Feb 17) may have introduced or re-introduced the snapshot capture bug.
Practical impact
Less severe than originally reported — git, node, pnpm, and all external executables work fine. Only shell builtins (echo, printf, pwd, type) have their output dropped. Workaround: node -e
"console.log(...)" instead of echo.
Updated diagnosis + confirmed v2.1.45 regression
Environment: Windows 11, MINGW64, Claude Code v2.1.45 (native installer)
After deeper testing, the original characterization ("all commands fail") is inaccurate:
What actually happens
Builtins with stdout -- FAIL (exit 1, no output):
Builtins with redirected/no stdout -- WORK:
External commands -- WORK:
Mixed chains:
Key findings
works.
onecmd re-injected. Old snapshots are not reused.
Confirmed regression: v2.1.45
Downgrading to v2.1.44 via npm install -g @anthropic-ai/claude-code@2.1.44 fully resolves the issue. The snapshot files generated by v2.1.44 do NOT contain set -o onecmd.
Workaround
Downgrade to v2.1.44 and disable auto-updates (/config -> Auto-update channel -> disabled, or DISABLE_AUTOUPDATER=1).
Related: #19057 (same root cause, but reports go back to v2.1.20 -- may be intermittent in earlier versions and consistent in v2.1.45)
Confirmed regression 2.1.44 -> 2.1.45 . Reproducible on native installer, the model complains about not receiving output from commands.
Generated the following report:
Bug Report
Summary
In version 2.1.45, all Bash tool calls silently return exit code 1 with no output on Windows with MINGW64/Git Bash. This is a regression from
2.1.44 where the same commands work correctly. The issue is not related to permissions — even with "Bash(*)" in the allow list, commands still
fail.
Environment
Steps to Reproduce
Expected Behavior
The command executes and returns output.
Actual Behavior
Exit code 1, no output, no error message — regardless of permission settings.
Confirmation that it's not a permissions issue
Setting "Bash(*)" in .claude/settings.local.json does not fix the problem
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.