claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Go binaries hang 30-60 seconds in Bash tool on macOS (stdin issue)

Open jimweller opened this issue 2 months ago • 4 comments

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

jimweller avatar Dec 05 '25 06:12 jimweller