[BUG] Running Claude Code causes all running apps to crash - MacOS

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 12 comments · opened Mar 11, 2025 · closed Mar 21, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 0.2.36 on Node version: v22.14.0
  • Operating System: macOS 14.7.1
  • Terminal: iTerm2

Bug Description

After updating to 0.2.36 when I run claude in a directory I previously it with, I see the welcome message and immediately all my open apps close, including the iTerm2 app I'm running claude in. Some apps will reopen automatically but most will not, including widgets that live in my macOS toolbar (like Alfred), requires logging out and back in to restore.

Steps to Reproduce

  1. run claude

Expected Behavior

Apps don't crash

Actual Behavior

All open apps crash.

Additional Context

There's no output to capture from claude because the terminal closes before I can copy anything.

View original on GitHub ↗

12 Comments

sharatvisweswara · 1 year ago

There is no output from claude --debug --verbose to help. I tried a screen recording but it crashes before it can save the file. Best I could do was take a video from my phone.

https://github.com/user-attachments/assets/54430fea-bd6d-43f0-bfed-abb73e152c10

sharatvisweswara · 1 year ago

Downgrading to 0.2.35 fixes the issue, no crashes so far. I have disabled auto update for now.

wolffiex collaborator · 1 year ago

wow thank you for this report

wolffiex collaborator · 1 year ago

are you using claude's MCP features by chance? do you have Claude Desktop installed?

sharatvisweswara · 1 year ago

i do have Claude Desktop installed with multiple MCP servers that I use without issue. I did use MCP servers with Claude Code but I made sure to remove them before I reproduced the issue for this bug report.

sharatvisweswara · 1 year ago

The issue is happening with Claude 0.2.50 as well. I reverted to 0.2.49 and disabled auto update, that does not crash.

wolffiex collaborator · 1 year ago

Sorry for this bad crash. I have a feeling this may be related to the way that claude code tries to source your .zshrc file.
In Claude's shell, CLAUDECODE env var is set. Any chance you can condition the logic in your .zshrc file to identify what may be causing this crash? It would us tremendously to narrow down the issue.

sharatvisweswara · 1 year ago

@wolffiex good call. This is the part that's breaking it:

export NVM_DIR=~/.nvm
[ -s "$(brew --prefix nvm)/nvm.sh" ] && source "$(brew --prefix nvm)/nvm.sh"

And the contents of my nvm.sh that it's sourcing there:

➜ cat  /usr/local/opt/nvm/nvm.sh
# $NVM_DIR should be "$HOME/.nvm" by default to avoid user-installed nodes destroyed every update
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
\. /usr/local/Cellar/nvm/0.40.1/libexec/nvm.sh
# "nvm exec" and certain 3rd party scripts expect "nvm.sh" and "nvm-exec" to exist under $NVM_DIR
[ -e "$NVM_DIR" ] || mkdir -p "$NVM_DIR"
[ -e "$NVM_DIR/nvm.sh" ] || ln -s /usr/local/opt/nvm/libexec/nvm.sh "$NVM_DIR/nvm.sh"
[ -e "$NVM_DIR/nvm-exec" ] || ln -s /usr/local/opt/nvm/libexec/nvm-exec "$NVM_DIR/nvm-exec"
wolffiex collaborator · 1 year ago

ok wow interesting, thanks so much for bisecting. hoping you can use CLAUDECODE for now to keep this from crashing (and turn the auto-updater back on :) and I will work on the repro and the fix

wolffiex collaborator · 1 year ago

Ok, looking at this more closely, I think this is the issue:

The real problem is a potential infinite recursion loop:

  • When the user runs the terminal, their .zshrc runs and executes:

export NVM_DIR=~/.nvm
[ -s "$(brew --prefix nvm)/nvm.sh" ] && source "$(brew --prefix nvm)/nvm.sh"

  • The brew --prefix nvm command runs, which itself may trigger shell initialization
  • Inside nvm.sh, there's another issue - it tries to source

/usr/local/Cellar/nvm/0.40.1/libexec/nvm.sh which might be creating a recursive
sourcing situation

  1. This recursion rapidly consumes memory and file descriptors, eventually crashing the

entire terminal

  1. The specific line \. /usr/local/Cellar/nvm/0.40.1/libexec/nvm.sh in the user's

nvm.sh file is suspicious - the backslash before the dot (.) forces sourcing even if
the file was already sourced

To fix this, the user should:

  1. Replace dynamic path resolution with hardcoded paths:

export NVM_DIR=~/.nvm
[ -s "/usr/local/opt/nvm/nvm.sh" ] && source "/usr/local/opt/nvm/nvm.sh"

  1. Or avoid nvm.sh entirely and use a simpler NVM setup:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

The problem appears to be that the nvm.sh script might be sourcing itself recursively
through a combination of the brew --prefix command and how nvm sets up its paths,
causing a terminal crash.

If you want to keep the logic as-is you can always use CLAUDECODE env var to condition it, but it seems like this may be a mistake in your shell logic

nickamorim · 1 year ago

I'm also seeing this same issue but don't have NVM

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