[BUG] Bash onecmd option causes npm script output to be lost on Windows

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Jan 19, 2026 · closed Jan 19, 2026

Environment

  • Claude Code version: VS Code Extension (latest)
  • Operating System: Windows 11
  • Shell: Git Bash (via CLAUDE_CODE_GIT_BASH_PATH)
  • Node version: v24.x

Bug Description

When running npm scripts (like npm run build) through Claude Code's Bash tool, the output is completely lost/invisible. The commands execute successfully but return no output to Claude.

Root Cause

Claude Code sets the bash onecmd option (equivalent to set -t) in SHELLOPTS when spawning bash processes. This option causes bash to exit after reading and executing one command.

When npm runs scripts with shebang (e.g., #!/usr/bin/env node), the onecmd option causes the parent shell to exit before the script can produce output.

Evidence:

$ echo $SHELLOPTS
braceexpand:hashall:igncr:interactive-comments:monitor:onecmd

Even spawning a fresh bash instance shows onecmd is set:

$ bash -c 'echo $SHELLOPTS'
braceexpand:hashall:igncr:interactive-comments:onecmd

Steps to Reproduce

  1. Open Claude Code in VS Code on Windows with Git Bash configured
  2. Ask Claude to run npm run build (or any npm script that uses node)
  3. Observe that the command completes but no output is shown

Expected Behavior

npm script output should be visible to Claude, showing compilation results, errors, etc.

Actual Behavior

Commands execute but return empty output or "no content", making it impossible to verify build success or diagnose errors.

Workaround

Prefix all bash commands with set +o onecmd;:

set +o onecmd; npm run build 2>&1

This disables the onecmd option before running the actual command.

Suggested Fix

Don't set the onecmd (-t) option when spawning bash processes, or provide a configuration option to control shell options.

Related Issues

  • #5041 - Bash output not getting picked up (closed as duplicate, but root cause not identified)
  • #4507 - Git Bash path issues

View original on GitHub ↗

6 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/19057
  2. https://github.com/anthropics/claude-code/issues/18856
  3. https://github.com/anthropics/claude-code/issues/18775

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

KuceraJanSupport · 7 months ago

Closing as duplicate of #19057 which has a more detailed root cause analysis. The issue is the same: set -o onecmd in shell snapshots breaks npm/subprocess stdout on Windows/Git Bash.

EyeSeeEm · 7 months ago

Still broken in v2.1.19 on Windows 11 + Git Bash.

Reproduction:

  • npm view @anthropic-ai/claude-code version → no output
  • claude --version → no output
  • Both commands work fine via node -e "console.log(require('child_process').execSync('...').toString())"

Workaround for others: Use the node execSync wrapper instead of direct commands.

This is blocking basic version checking and update workflows.

salvadorplj · 7 months ago

This is still an issue on Claude Code 2.1.x, Windows 11, Node v24.12.0 with Git Bash. Running npm run test (vitest) through the Bash tool returns empty output and exit code 0 even when tests are failing. This caused broken code to be pushed to CI multiple times because Claude believed tests passed when they didn't.

tobq · 6 months ago

Still broken

github-actions[bot] · 6 months ago

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.