[BUG] Go binaries hang 30-60 seconds in Bash tool on macOS (stdin issue)
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?
Go binaries (go, bd, custom programs) hang for minutes before succeeding when executed via Claude Code's Bash tool on macOS. Works instantly on Linux. Standard Unix commands (date, ls, pwd) work fine. Redirecting stdin makes go binaries work normally.
Environment
- macOS: Darwin 24.6.0 (arm64)
- Go: go1.25.5 darwin/arm64
- Claude Code: 2.0.30-2.0.59 (tested multiple versions)
- Shell: Tested both zsh and bash
- Terminal: Tested iTerm2, VSCode and Terminal.app
Reproduction
# These hang 30-60 seconds on macOS:
go version
bd version
# These work instantly:
npm
date
pwd
ls
Root Cause
Claude Code's Bash tool provides stdin as a named pipe (Srw-rw-rw-) that blocks on read. Test program shows:
stat, _ := os.Stdin.Stat()
fmt.Printf("Mode: %v\n", stat.Mode()) // Output: Srw-rw-rw-
fmt.Printf("Is CharDevice: %v\n", (stat.Mode() & os.ModeCharDevice) != 0) // Output: false
// Attempting to read blocks for 2+ seconds
The Go runtime appears to check stdin during initialization, causing the hang.
Workaround
Redirect stdin to /dev/null:
go version < /dev/null
Platform Behavior
- macOS: Hangs
- Ubuntu 24.04.3: Works instantly
This seems macOS-specific, not shell or terminal-specific.
What Should Happen?
go binaries should run in claude code for the same durations they run outside claude code.
Error Messages/Logs
n/a
Steps to Reproduce
launch claude code on MacOS.
prompt claude code to run "go version"
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.59
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
6 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is similar to 12507, but for MacOS. Downgrading to 2.0.25 like that issue did not work for me on MacOS. The
spawn()suggestion from that issue seems sane.I tried three different languages to reproduce stdin behaviors with the claude Bash tool. node and go both fail. python succeeds. They do eventually succeed when the pipe finally produces EOF.
node
go
python
Sampled a hanging Node.js process using macOS
sampletool and confirmed it's blocked in thekeventsyscall:Out of 2265 samples over ~7 seconds, 2248 (99.25%) were blocked in
keventwaiting for stdin I/O that never completes.Call stack shows:
node::SpinEventLoopInternal- Node.js event loopuv_run→uv__io_poll- libuv I/O pollingkevent- waiting for stdin file descriptor to become readableThis indicates the stdin socket never closes and never provides data, causing the event loop to block indefinitely on macOS.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
go versionis working quickly on claude code 2.0.76.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.