cursor icon indicating copy to clipboard operation
cursor copied to clipboard

[BUG] Agent Mode Terminal Ignores ZSH Profile Setting and Forces Bash

Open psuzzi opened this issue 1 year ago β€’ 3 comments

Description:

When using Cursor's Agent Mode terminal, the shell defaults to bash regardless of the selected terminal profile settings.

Steps to Reproduce:

  1. Clean install Cursor
  2. Set default terminal profile to "zsh" in Cursor's terminal profile settings
  3. Use Agent Mode terminal

Current Behavior:

Terminal launches with bash using command: /bin/bash --init-file /Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-bash.sh

  • Environment shows inconsistent state:
    • Process runs as /bin/bash
    • $SHELL is set to /bin/zsh
    • Error messages show bash: "bash: command not found"

Expected Behavior:

  • Terminal should launch using zsh as specified in the profile settings
  • Should use appropriate zsh integration script
  • Environment variables and actual shell process should consistently reflect zsh

Environment:

  • OS: macOS 24.3.0
  • Shell: zsh set as default
  • Cursor Version: 0.47.8 (Universal)
  • Clean installation with no previous configuration files

Additional Notes:

  • The issue persists after a complete reinstall and clearing all configuration
  • The zsh integration script appears to be missing from the expected location in the Cursor application files

Workaround:

For each command running in agent mode, I can run it on zsh only if I tell the agent to prepend the command with a command to correct the shell activation.

Example:

  • to run pnpm test
  • the agent need to run /bin/zsh -il -c "pnpm test"

This workaround is not really acceptable. --> Please, let me know if there is something more permanent, so that I don’t have to prepend the shell activation to all commands.

Similar Bugs

There is a number of similar bugs with Terminal in Agent mode, but none is detailed enough to explain the problem comes from the Agent not using the correct terminal configuration.

I also reported this issue in the forum:

  • https://forum.cursor.com/t/agent-mode-terminal-ignores-zsh-profile-setting-and-forces-bash/68663

psuzzi avatar Mar 23 '25 14:03 psuzzi

This happens in Agent Mode only.

Here is a screenshot to quickly show the bug

Image

psuzzi avatar Mar 23 '25 14:03 psuzzi

Cursor Terminal Shell Configuration Bug Investigation

Initial Environment Check

  • $SHELL shows /bin/zsh
  • Actual running process shows /bin/bash
  • Terminal is launched by "Cursor Helper: terminal pty-host"

Configuration Attempts

1. Workspace Settings (.vscode/settings.json)

{
    "terminal.integrated.defaultProfile.osx": "zsh",
    "terminal.integrated.profiles.osx": {
        "zsh": {
            "path": "/bin/zsh",
            "args": ["-l"],
            "overrideName": true
        }
    }
}

2. Cursor Global Settings (~/Library/Application Support/Cursor/User/settings.json)

{
    "terminal.integrated.defaultProfile.osx": "zsh",
    "terminal.integrated.profiles.osx": {
        "zsh": {
            "path": "/bin/zsh",
            "args": ["-l"],
            "overrideName": true
        }
    }
}

3. VS Code Global Settings (~/Library/Application Support/Code/User/settings.json)

  • Added the same terminal configuration
  • Noted existing setting "terminal.integrated.inheritEnv": false

Environment Variables Check

  • SHELL=/bin/zsh
  • RBENV_SHELL=zsh
  • TERM_PROGRAM=vscode
  • TERM=xterm-256color
  • Various Cursor/VS Code specific variables present

Process Hierarchy

  • Terminal process β†’ Cursor Helper: terminal pty-host β†’ Cursor.app

Results

  • After each configuration change and restart, the terminal still defaults to bash
  • Environment variables correctly indicate zsh
  • The issue persists regardless of configuration location (workspace, Cursor global, or VS Code global)

Current Workaround

  • Prepending commands with /bin/zsh -il -c to force zsh execution

This appears to be a bug in Cursor's terminal implementation where it's not properly respecting the shell configuration settings, despite the environment variables being correctly set for zsh.

psuzzi avatar Mar 24 '25 15:03 psuzzi

For me the agent always defaults to pwsh instead of zsh. I uninstalled pwsh for now. OS is Ubuntu 24.04.

semidark avatar Apr 22 '25 11:04 semidark

Similar issue here - Ubuntu 22.04.5, zsh via oh-my-zsh

similark avatar May 01 '25 09:05 similark

Tried solution from here and executed cursor with sudo - it solves the issue for current session. I don't like the idea of running it with sudo but I guess it could be treated as workaround and maybe that could also give some hints for the root cause

kopach avatar May 17 '25 17:05 kopach

executed cursor with sudo

Running cursor with sudo is the only working solution for me as well, in addition to these settings:

 "terminal.integrated.defaultProfile.osx": "zsh",
  "terminal.integrated.profiles.osx": {
    "zsh": {
      "path": "/bin/zsh"
    }
  },
  "terminal.integrated.shellIntegration.enabled": false,
  "terminal.integrated.automationProfile.osx": {
     "path": "/bin/zsh"
  },
  "terminal.integrated.automationShell.osx": "/bin/zsh"

alexthewilde avatar May 29 '25 14:05 alexthewilde

Finally got it working without sudo for me. In my case, the root cause was not in ZSH profile not being properly applied but rather in how Cursor parses multi-line terminal output. See details here: https://github.com/getcursor/cursor/issues/3139#issuecomment-2921863716

kopach avatar May 30 '25 10:05 kopach

  • Thank you for all the supporting comments. πŸ™
  • I am wondering if this issue has been permanently fixed or if there is an alternative workaround other than using sudo.

foreverLoveWisdom avatar Jun 16 '25 09:06 foreverLoveWisdom

This is pretty bad. I was wondering why commands were messing up my environment and often failed. This bug should be prioritized!

I refuse to use sudo and the other settings don't seem to work for me.

delambo avatar Jul 28 '25 21:07 delambo

I am also getting this error. Here are the console errors.

$ /bin/zsh -l (eval):3: parse error near `cursor_snap_ENV_VARS...' zsh:1: command not found: dump_zsh_state

And here is the relevant part of my config JSON


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

cyotee avatar Sep 17 '25 19:09 cyotee

idk if this will help someone but the following config works for me on mac os (darwin hardware) with bash as default shell

  1. completely remove cursor and it's settings files (not the rules!) and install back (tried both brew and direct download from website)
  2. corrected .bashrc
dump_bash_state() { :; }
export -f dump_bash_state 2>/dev/null
  1. corrected .bash_profile
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/bin:$HOME/.local/bin"

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

  1. corrected settings.json
{
    "window.commandCenter": true,
    "terminal.integrated.shellIntegration.enabled": false,
    "terminal.integrated.defaultProfile.osx": "bash",
    "terminal.integrated.automationProfile.osx": {
      "path": "/bin/bash",
      "args": ["-l"]
    }
  }

I think, key fix is this: terminal.integrated.shellIntegration.enabled: false Credits: https://forum.cursor.com/t/how-to-fix-cursor-agent-not-using-default-zsh-shell-on-macos/37734/6

PS For me this works without sudo

gleruzh avatar Sep 29 '25 19:09 gleruzh

I'm getting this error: node: command not found - when the agent executes any command, but if I run it in the Cursor terminal it works perfectly. I have zsh and nvm, but in the agent when I do echo $SHELL it shows /bin/bash. I can only run something if I do it like this: /bin/zsh -l -c "npm command".

My configuration:

"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"

.zshrc

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

if [ -s "$NVM_DIR/nvm.sh" ]; then
  export PATH="$NVM_DIR/versions/node/$(nvm version)/bin:$PATH"
fi

Any suggestions?

saomartinho avatar Oct 03 '25 13:10 saomartinho

Opposite problem: agents ignore all other config and use a zsh subprocess instead of my desired shell.

byronbowerman avatar Oct 10 '25 15:10 byronbowerman

please allow external iterm app to be used , this is really a big bug as I have my own zshrc which I can ideally use. Agent must use my open zsh shell if its there. This should be the best solution if the worry is breakage of sandbox. Although the sandbox is owned by curosr , the commands side effects are owned by me. Please fix this as is a problem for lot of developers. I would like to audit the commands executed by the curosr from my zsh history , I am already doing this for other commands I type. why not for commands generated by curosr.

cloudbow avatar Oct 11 '25 10:10 cloudbow

Still Experiencing This Bug in November 2025 (8 Months Later)

I'm getting the exact same error as reported in March 2025:

(eval):3: parse error near `cursor_snap_ENV_VARS...'
zsh:1: command not found: dump_zsh_state

Environment

  • macOS (Darwin)
  • Cursor: Latest version except last update Nov 20th 2025
  • Shell: zsh (set as default)
  • 8 months after original report, issue still persists

The Root Cause (From Thread Analysis)

Looking at the discussion, the issue stems from Cursor's shell integration injection conflicting with zsh configuration:

  1. @cyotee (Sep 17) - Reported identical dump_zsh_state parse error with shell integration enabled
  2. @gleruzh (Sep 29) - Found that disabling shell integration fixes it: "terminal.integrated.shellIntegration.enabled": false
  3. Multiple users - Confirm the workaround works: /bin/zsh -il -c "command"

Solution That Worked For Me

Instead of disabling shell integration entirely (which breaks state persistence), I added a defensive stub to ~/.zshrc:

if [[ -n $CURSOR_TRACE_ID ]]; then
  dump_zsh_state() { echo ""; }
  precmd() { print -Pn "\e]133;D;%?\a" }
  preexec() { print -Pn "\e]133;C;\a" }
fi

Why This Works Better Than Previous Solutions

  • βœ… Keeps shell integration enabled (maintains state persistence between commands)
  • βœ… Stubs out the broken dump_zsh_state function with a no-op
  • βœ… Uses standard ANSI escape sequences (precmd/preexec) instead of Cursor's broken injection
  • βœ… Only affects Cursor terminals (via $CURSOR_TRACE_ID detection)
  • βœ… Doesn't require running Cursor with sudo (unlike @kopach/@alexthewilde workaround)
  • βœ… Simpler than full shell integration disable (per @gleruzh)

After This Fix

$ cd /my/project
$ /usr/local/bin/php -v      # Works without errors
$ npm install                 # Still in /my/project βœ…

Recommendation for Cursor Team

This issue has persisted for 8 months across multiple OS/shell combinations. The root cause appears to be Cursor's dump_zsh_state injection mechanism incompatibility with standard zsh configurations. Consider:

  1. Switching to standard ANSI escape sequences (what this fix implements)
  2. Or fixing the shell integration script injection logic
  3. Or providing a built-in way to disable just dump_zsh_state without disabling all shell integration

The stub approach demonstrates it's fixable at the user level, suggesting the code path is discoverable.

rovony avatar Nov 20 '25 23:11 rovony