Bash command timeouts due to shell hangs

Resolved 💬 36 comments Opened Feb 24, 2025 by ekvanox Closed Mar 5, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
Bash commands always timeout with code 143. I use MacOS with fish, tmux, & alacritty. I get the same problem in the default MacOS terminal with bash (without tmux).

Environment Info

  • Platform: macos
  • Terminal: tmux
  • Version: 0.2.9
  • Feedback ID: 66dc2745-228b-47a3-a286-30ea14afc296

Example:

> Can you merge in the dev branch? Make sure it is up to date with the remote first. Make resonable choices about what to get, and make sure not to remove functionality, but to instead combine it with the changes on the current branch.

⏺ I'll merge the dev branch into our current branch, making sure to get the latest remote changes. Let me handle this for you.

⏺ Bash(git branch -a)…
  ⎿  Command execution timed out
     Exit code 143

⏺ Bash(git branch -a)…
  ⎿  Command execution timed out
     Exit code 143

⏺ Let me try using a different approach to get branch information.

⏺ Bash(git fetch && git branch)…
  ⎿  Command execution timed out
     Exit code 143

⏺ I'm having trouble with the git commands timing out. Let me try with a more focused approach:

⏺ Bash(git fetch origin dev && git merge origin/dev)…
  ⎿  Command execution timed out
     Exit code 143

⏺ Let me try breaking this down into smaller steps with shorter timeouts:

⏺ Bash(git fetch origin)…
  ⎿  Command execution timed out
     Exit code 143

⏺ It seems there might be network or repository issues causing timeouts. Let me try a different approach:

⏺ Bash(git remote -v)…
  ⎿  Command execution timed out
     Exit code 143

⏺ I'm experiencing timeouts with git commands. This could be due to network issues or repository configuration. Let me try one more approach:

⏺ Bash(git status)…
  ⎿  Command execution timed out
     Exit code 143

View original on GitHub ↗

36 Comments

darinkishore · 1 year ago

Getting the same problem. Wonder if it's something to do with fish?

bobisme · 1 year ago

same thing here. fish and ghostty. but I dropped into a bash shell in Terminal.app and experienced the same thing

darinkishore · 1 year ago

I also tried using zsh as login shell, env -i HOME=$HOME PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin zsh -l and then running Claude direct from the binary path, met with same issue .

sshed into a linux server that has fish and bash, dropped into bash, same issue (half the time it crashes instead).

ekvanox · 1 year ago
Getting the same problem. Wonder if it's something to do with fish?

seemed plausible to me (had similar problems when using sgpt when using fish) but i'm getting the same issue from bash too

gerred · 1 year ago

note that sudo claude seems to help with this, at the cost of messing up other operations (commits get created as root for one, and then ssh-agent . I'm also using mise for node+npm, but it persisted when using fnm as well. persists when I do sudo -u $USER claude.

bobisme · 1 year ago

also using mise here

ekvanox · 1 year ago
note that sudo claude seems to help with this, at the cost of messing up other operations (commits get created as root for one, and then ssh-agent . I'm also using mise for node+npm, but it persisted when using fnm as well. persists when I do sudo -u $USER claude.

thanks, can confirm this allows claude to run commands (but introduces other problems caused by sudo usage)

darinkishore · 1 year ago

also used mise! uninstalled, problem seems to have persisted.

gerred · 1 year ago

I swapped to the homebrew version of zsh, w/ mise and oh-my-posh still, ran claude, !ls works consistently now (where it wasn't before even running any bash command without running it through Sonnet).

docs say fish isn't supported but zsh is, but doesn't explain the behavior reported before. I did ensure I was using mise and installed via mise use -g npm:@anthropic-ai/claude-code.

with ghostty, I also had to COMPLETELY close ghostty, not just open a new terminal tab, before my shell would actually switch.

bobisme · 1 year ago

ok, I think i've solved it. it's the $SHELL env var.
I ran this in fish:

SHELL=/bin/bash claude

and commands ran fine

devondragon · 1 year ago

Same issue here (fwiw I use zsh and mise), but @bobisme's comment above seems to work for me.

antiartificial · 1 year ago

Encountering the same issue and @bobisme var setting solved it. Thank you for sharing!

darinkishore · 1 year ago

for me, the shell setting didnt help, but sudo did (even while still using fish).

nehalecky · 1 year ago

I'm running zsh (ala brew), and can confirm that running

SHELL=/opt/homebrew/bin/zsh claude

works, per @bobisme 's comment above. Thanks all!

Edit: P.S. This might suggest that claude isn't resolving default shell from env var. I can't check now, but will try later this week!

jkuball · 1 year ago

I had shell set to a path in my nix store (/nix/store/2hq38y4h3793c1x686z2vv4fvjmp4wc1-fish-3.7.1/bin/fish) which also triggered the issue.

If you use claude-code from nixpkgs-master, as a short fix, you can just override the SHELL for the claude binary.

pkgs.claude-code.overrideAttrs
    # Fix for https://github.com/anthropics/claude-code/issues/35
    # Probably not needed anymore really soon.
    (oldAttrs: {
      postFixup = ''
        wrapProgram $out/bin/claude \
          --set SHELL bash
      '';
    });

I presume this is a really short lasting issue, but maybe someone can profit from my fix.

Edit: To clarify, no need to use sudo (not sure if this ever would be a good idea to give claude sudo rights), and also you probably have to make sure you have bash in your path).

bcherny collaborator · 1 year ago

This should be feeling better on 0.2.18. Restart to update.

wolffiex collaborator · 1 year ago

We landed a fix for fish shell with 0.2.18 so hopefully you 🐟 users should be happier. However, the shell can hang for a variety of reasons. We will continue to track these down with your help. Please make sure you are using one of our supported shells: bash, zsh or fish.

bobisme · 1 year ago

Thanks! I updated, but it's still hanging in fish :(

!Image

SHELL=/bin/bash claude # still works
darinkishore · 1 year ago

same behavior on fish! (macos)

SHELL=/opt/homebrew/bin/bash claude does not fix unfortunately.

sudo works.

0.2.18

gerrywastaken · 1 year ago

For the record, fish user on linux

SHELL=/bin/bash claude - fixed this issue for me

I wonder what the commonality is for the people where it didn't work.

wolffiex collaborator · 1 year ago

Ok, I'll continue to add logging. Right now, we try to spawn a login shell because I am lazy. I can implement the startup sequence in the app. I'll test this a little bit and report back.

The other issue could be locating a shell executable. I added logging for that.

bastien-k · 1 year ago

Also fish user here, and SHELL=/bin/bash fixed it.
However, for some reason, I never managed to get claude command in my path, so I ended with a fish function:

function claude
    SHELL=/bin/bash /home/bastien/.npm-global/bin/claude
end
gerrywastaken · 1 year ago
Ok, I'll continue to add logging. Right now, we try to spawn a login shell because I am lazy. I can implement the startup sequence in the app. I'll test this a little bit and report back. The other issue could be locating a shell executable. I added logging for that.

It could always be a config option for the user to supply the path, or you could have claude code find it for them 😁

bobisme · 1 year ago

I'm curious if the tool is trying to use bash, specifically, or it's trying to use the user's shell. I see the tool is called BashTool internally, so I assumed it was just bash. I would be fine with that even though I use fish as my interactive shell.

Of course, if the source were open, we could help debug 😉.

wolffiex collaborator · 1 year ago

BashTool is a misnomer. It should be called ShellTool. We support bash, zsh, and fish and try to choose the right one.

bitconym · 1 year ago
We landed a fix for fish shell with 0.2.18 so hopefully you 🐟 users should be happier. However, the shell can hang for a variety of reasons. We will continue to track these down with your help. Please make sure you are using one of our supported shells: bash, zsh or fish.

Is Fish shell officially supported? On your website you still have the information that Fish is not supported.

!Image

GurgehMorat · 1 year ago

I'm in Mac with Fish and I have this issue

 ~/d/claude-chat   *…  claude --version                                                  58.5m  Sat Mar  1 13:23:17 2025
0.2.29 (Claude Code)
jtamboli · 1 year ago

Using Claude 0.2.29 under Fish 4.0.0 I'm seeing problems with spaces in paths. I'm not sure if this problem is related to this Issue, but I'd rather not burn more tokens investigating. If there's a way for me to get additional debugging information, please let me know.

I'm running from inside a path like "/Volumes/MyDrive/Source/Foo Bar", and there's also a "/Volumes/MyDrive/Source/Foo" directory.

When I run claude under fish with no SHELL environment override, and I simply command it to "commit", I get a timeout.

When I run env SHELL=/bin/bash claude and command it to "commit", it seems to ignore spaces in the path. I used claude-code to make changes to several files in "/Volumes/MyDrive/Source/Foo Bar", but when I tell it "commit" it outputs:

⏺ Bash(git status)…
  ⎿  On branch main
     nothing to commit, working tree clean
  ⎿  Shell cwd was reset to /Volumes/MyDrive/Source/Foo Bar
                                      
⏺ There are no changes to commit. Your working tree is clean.

(Under an earlier version of claude-code, it made and committed a bunch of changes in "/Volumes/MyDrive/Source/Foo", but I don't remember all the details.)

jrobgood · 1 year ago

Whitespace in filenames (or obviously their paths) is the repeatable culprit for me here. Factory zsh with and without oh-my-zsh enhancements. No amount of SHELL or PATH finagling made any difference.

find . -type f -name "* *" | while read file; do mv "$file" ${file// /_}; done is your friend to reel you back from the comforting embrace of OS X and slap you with a dose of common sense.

dmd · 1 year ago

I do not have any spaces in the path I'm running in (under Fish 4, on MacOS). In fact I can reproduce this in /tmp/foo.

bobisme · 1 year ago

@wolffiex did you mean to close this as a duplicate of #208? That reads like a different issue

wolffiex collaborator · 1 year ago

sorry, my fault. this is still live but we have some updates coming. we are testing a fix where claude always gets a POSIX shell even if the user's shell is set to something different. we will let it bake for a bit then roll it out.

wolffiex collaborator · 1 year ago

Hi everyone, thanks for your patience with this. We just pushed v0.2.32 which hopefully will fix most of the issues here. The details:

  • Before, we'd just try to run your $SHELL if it was set. This caused some problems.
  • Claude is good at POSIX shells like bash and zsh, but not so much fish and nu or others
  • Now, we do our best to locate an executable for zsh or bash (in that order, unless you are running bash) and run that as a login shell
  • If we find ~/.[z|b]shrc we try to source that so you and claude can share aliases and env vars

We try to find a shell a few ways:

  • running which [b|z]sh
  • from your $SHELL env var if it looks like it is bash or zsh
  • from some known places on linux and mac

You shouldn't need to do this anymore:

SHELL=/bin/bash claude

If you update and things are still broken, please let us know!

wolffiex collaborator · 1 year ago

closing, please start over additional feature requests or new bug reports

Anna-Pinewood · 11 months ago

Thank you so much! It has also helped, since i was using zshell.
I had a problem with claude code running bash commands. It seemed to freeze. It couldn't run any of bash commands and time-outs after 2 minutes. But it still could write its own tools – create files, editing them. And all Bash(...) calls seemed to fail

● Perfect! Now stop the server and restart it. Or better yet, let me create a
  simpler solution using just the Vite dev server with the conversion:

● Bash(cd /home/user/workspace/llm-facts/view && python convert_data.py)
....

Turned out it was because i was using it in zshell.

  1. Commented out this line exec /usr/bin/zsh in ~/.bashrc.
  2. Ran bash --login, echo $0 - should print bash
  3. And then ran claude here. And all commands starts executing!
github-actions[bot] · 11 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.