[BUG] Bash commands hang indefinitely in VSCode

Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Dec 9, 2025 · closed Dec 9, 2025

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?

All bash commands hang indefinitely
VSCode integrated terminal works

VSCode Remote-SSH environment
Extension version 2.0.62
CLAUDE_BASH_NO_LOGIN=1 doesn't help
Remote host: RHEL-based Linux

What Should Happen?

Claude should be able to run commands through bash on the remote environment

Error Messages/Logs

Steps to Reproduce

I do not know if this is reproducible for others. I worked with Claude itself on debugging and Claude asked me to file this report.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.58

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

5 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11689
  2. https://github.com/anthropics/claude-code/issues/3153
  3. https://github.com/anthropics/claude-code/issues/12353

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

gramatus · 10 months ago

I had a similar issue and after quite a lot of debugging, I realized that it was my bash profile setup that caused the issue. I'll add the summary we created after that here, in case it might be the same issue.
The key takeaway: Have Claude look into shell startup issues.

Claude Code Bash Delays: Root Cause & Resolution

Summary

Claude Code bash commands hanging indefinitely in GitHub Codespaces was caused by dotfiles shell configuration, not a Claude Code bug.

Root Cause

.bash_profile contained exec /bin/zsh -l without an interactive shell guard:

  • Claude Code spawns non-interactive login shells for bash commands
  • exec /bin/zsh -l caused bash to immediately replace itself with zsh
  • Oh-My-Zsh async functions loaded in this context created infinite loops
  • Result: commands appeared to hang indefinitely

Fix

Add interactive shell guard in .bash_profile:

# Only switch to zsh for interactive sessions
if [[ $- == *i* ]]; then
    exec /bin/zsh -l
fi

Key Lessons

  1. Claude Code shell behavior: Spawns non-interactive login shells — dotfiles must handle this gracefully
  2. Environment-specific issues: Problem only appeared in Codespaces with custom dotfiles, not in fresh environments
  3. Misleading symptoms: The "Inferring..." delay looked like AI inference overhead, but was actually shell initialization hanging

Debugging Approach That Worked

  • Tested across multiple environments (Windows native, WSL, Codespaces)
  • Added logging to shell initialization files to trace execution
  • Isolated the issue to dotfiles by testing with/without custom configuration

Obsolete Workarounds (No Longer Needed)

The following workarounds were developed before root cause was found — they're unnecessary now:

  • Disabling Bash tool in .claude/settings.local.json
  • CLAUDE.md instructions for alternative tools
  • Pipe-to-file pattern for command execution
  • Ctrl+B background mode for every command
nadime · 10 months ago

Thanks - yeah this wasn't the problem. I also assumed it was a shell/profile/rc problem, but after debugging for an hour with Claude helping me, I don't believe that's the case anymore. We set things up to use an incredibly minimal .bashrc and it's still hanging (even with full VSCode reload, etc.).

nadime · 10 months ago

I'm not sure this is gonna be helpful, so closing. I'm going to try to reproduce more reliably.

github-actions[bot] · 10 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.