How to Fix Cursor Agent Not Using Default zsh Shell on macOS?

I’m encountering an issue while using the Cursor Agent in my development environment on macOS. My default shell is set to zsh (configured with oh-my-zsh), but the Agent seems to be executing commands in a different shell.

As a result, commands like node and python, which are installed on my system and work perfectly fine in my terminal, fail to execute with the error: command not found.

I’ve double-checked my configurations, and the default shell for my system is indeed zsh.

Does anyone know how to ensure the Cursor Agent uses the default zsh shell for executing commands? Any help would be greatly appreciated!

7 Likes

Can you please move this discussion to ‘How To’?

1 Like

I’m facing the same issue. It cannot find any command even though I can find it through the regular VS Code terminal.

The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
For more details, please visit Use zsh as the default shell on your Mac - Apple Support.
Tushars-MacBook-Pro:ctf tusharchopra$ pnpm dlx shadcn-ui@latest add select
bash: pnpm: command not found
Tushars-MacBook-Pro:ctf tusharchopra$ npm install -g pnpm
bash: npm: command not found

I was facing the same issue. I installed fish-terminal, and all of a sudden Cursor started using fish. I uninstalled fish, and now it’s defaulting to bash, and still is not using zsh.

In my settings.json file, I have "terminal.integrated.defaultProfile.osx": "zsh", and the issue remains.


I ask the agent to run a simple “ls” command and pop out the terminal. This is the process and terminal information.

(text in the photo transcribed)

ls

Process ID (PID): 20547

Command line: /opt/homebrew/bin/bash '--init-file' '/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh'

Shell integration activated

The following extensions have contributed to this terminal's environment:

* Git : Enables the following features: git auth provider

* Python : Activated environment for ./.venv/bin/python

Show Environment Contributions

My settings.json
“terminal.integrated.defaultProfile.linux”: “zsh”,
“terminal.integrated.defaultProfile.osx”: “zsh”,
“terminal.integrated.shellIntegration.enabled”: false,

by adding “terminal.integrated.shellIntegration.enabled”: false, in settings.json resolve the issue for me

13 Likes

YOU saved my life. I’d been looking for ages…

1 Like

This is a correct reply set “terminal.integrated.shellIntegration.enabled”: false, and not chsh -s /bin/zsh

2 Likes

This works for me too

Here is video on this.
The dudes got a thick indian accent, but it’s the shortest How to on this topic I could find.

Still can’t get cursor to pick up those settings. A hacky but effective workaround is to make bash automatically exec into zsh when it’s launched by Cursor’s Agent.

You can detect this because Cursor sets an environment variable: CURSOR_TRACE_ID.

Add this to your ~/.bash_profile (or ~/.bashrc if that’s what’s being sourced):

if [ -n "$CURSOR_TRACE_ID" ] && [ -z "$BASH_TO_ZSH" ]; then
  export BASH_TO_ZSH=1
  exec zsh
fi

Why this works:

  • CURSOR_TRACE_ID is set by Cursor Agent sessions, not by your normal terminal.
  • exec zsh -l replaces the current bash process with a login zsh shell.
  • The BASH_TO_ZSH guard prevents infinite loops in case zsh also calls back into bash somehow.
1 Like

I had a similar issue where Cursor couldn’t find things that perfectly works in my terminal.
In my case, I use bash but Cursor was trying to use zsh which doesn’t have all the alias, path, helpers…
(here lago is a docker composer command alias)

julien@Juliens-MacBook-Pro api % lago exec api bin/rails about
zsh: command not found: lago

I finally managed to make it work with this config:

{
    "terminal.integrated.sendKeybindingsToShell": true,
    "terminal.integrated.defaultProfile.osx": "bash",
    "terminal.integrated.shellIntegration.enabled": true,
    "terminal.integrated.env.osx": {
        "SHELL": "/opt/homebrew/bin/bash"
    },
}

Notice that you cannot define "/opt/homebrew/bin/bash" in "terminal.integrated.defaultProfile.osx".

This has been bugging me for days! Thank you all for your contributions!

1 Like

Thank you! That has stopped it trying to use zsh.

The following settings worked out for me:

{
    ...,
    "terminal.integrated.shellIntegration.enabled": true,
    "terminal.integrated.profiles.osx": {
        "zsh": {
            "path": "/bin/zsh",
            "args": ["-l"]
        },
        "bash": null
    },
    "terminal.integrated.automationProfile.osx": {
        "path": "/bin/zsh",
        "args": ["-l"]
    },
    "terminal.integrated.defaultProfile.osx": "zsh",
    "terminal.integrated.gpuAcceleration": "off"
}

Setting the automationProfile did the trick for me.
Turning off gpuAcceleration makes sure that the agent detects completion of a command.

I hope that helps!

2 Likes

Can confirm this does fix it on macOS Sequoia (15.6). Thanks for sharing :slight_smile:

Edit: Scrap that spoke to soon. It works sometimes , but most of the time is still unable to see terminal output. It can run a command, but cannot see the response.

This really needs to make its way into some official docs, it’s pretty poor on Cursors part that they aren’t detecting the default shell setup, zsh is very widely used amongst devs on macos.

@R1ck
Do you use a custom theme in your ZSH shell?

The official Cursor docs (Agent > Terminal) suggest to skip the theme initialization for better compatibility in Cursor.