Agent uses zsh instead of bash

Claude (set to default) always seems to use zsh instead of bash (which is my system wide shell, that vscode also uses).

Because of this, I frequently have it suggest to edit my zshrc or find that common commands, or version of node and similar don’t actually exist - because of course they don’t - I don’t use zsh.

I asked it why it uses zsh instead of bash and it told me that it was mentioned in its context that it should use zsh. I never said such a thing, so I assume it is Cursor’s own context who told it that.

I feel like this is a straight bug? Built in terminal respects the system-wide setting, and even Cursor context does, but the terminal tool it gives to claude seems to always do zsh.

Here is what Agent had to say about it:

I apologize - you’re asking WHY the commands are being executed in zsh when we were told you use bash.

The reason is: there appears to be a discrepancy between the user info provided (which says bash: /opt/homebrew/bin/bash) and what’s actually happening in the terminal (which is clearly running zsh, as evidenced by the % prompt and the “zsh: command not found” messages).

Let me break down the inconsistency in the tooling:

  1. In the initial user info I was given:
    The user’s shell is /opt/homebrew/bin/bash
  2. But when I run commands through the run_terminal_cmd tool, we see:
    • Commands are executing in zsh (evidenced by the % prompt)
    • The process shows /bin/zsh -il when we ran ps
    • The tool is ignoring the user info and using a different shell

This means there’s a bug in the run_terminal_cmd tool implementation - it’s not respecting the shell specified in the user info and is instead using the system’s default shell or VSCode/Cursor’s configured shell.

Context:
"PROPOSE a command to run on behalf of the user. If you have this tool, note that you DO have the ability to run commands directly on the USER's system."

This tool is a Cursor tool - it’s part of Cursor’s implementation for executing commands in the user’s environment. The discrepancy we’re seeing (between the stated bash shell and actual zsh execution) is likely a bug in how Cursor is handling shell execution, not respecting the shell information it provides to me.

I should report this inconsistency to the Cursor team - they’re telling me one shell (/opt/homebrew/bin/bash) in the user info, but their command execution is happening in a different shell (/bin/zsh).

After talking to Agent some more, it suggested I forcibly set the shell in settings.json which worked :slight_smile:

{
  "terminal.integrated.defaultProfile.osx": "bash",
  "terminal.integrated.profiles.osx": {
    "bash": {
      "path": "/opt/homebrew/bin/bash",
      "args": ["-l"]
    }
  },
}

Funnily enough - this fixes the issue, Agent now executes in bash but it still sometimes thinks we are using zsh (for example will suggest edits to .zshrc). When asked about it, it said:

The NVM configuration is in your .bash_profile, but on macOS, we should also check .zshrc since you’re using zsh (as indicated by your shell path).

When pressed on where on earth it got that idea, it apologised and plead stupidity:

My user info window states: The user's shell is /opt/homebrew/bin/bash

This clearly shows you are using bash, not zsh. I made an incorrect assumption based on the /opt/homebrew path, which is commonly used for Homebrew installations on macOS, but doesn’t indicate the shell type at all.
I made an incorrect assumption because:

  1. /opt/homebrew is the default installation directory for Homebrew on Apple Silicon Macs

  2. I incorrectly associated this path with zsh, which is the default shell on newer macOS versions