[BUG] Agent Mode Terminal Ignores ZSH Profile Setting and Forces Bash
Description:
When using Cursor's Agent Mode terminal, the shell defaults to bash regardless of the selected terminal profile settings.
Steps to Reproduce:
- Clean install Cursor
- Set default terminal profile to "zsh" in Cursor's terminal profile settings
- 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 -
$SHELLis set to/bin/zsh - Error messages show bash: "bash: command not found"
- Process runs as
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
This happens in Agent Mode only.
Here is a screenshot to quickly show the bug
Cursor Terminal Shell Configuration Bug Investigation
Initial Environment Check
-
$SHELLshows/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 -cto 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.
For me the agent always defaults to pwsh instead of zsh. I uninstalled pwsh for now. OS is Ubuntu 24.04.
Similar issue here - Ubuntu 22.04.5, zsh via oh-my-zsh
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
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"
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
- 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.
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.
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"
]
},
idk if this will help someone but the following config works for me on mac os (darwin hardware) with bash as default shell
- completely remove cursor and it's settings files (not the rules!) and install back (tried both brew and direct download from website)
- corrected .bashrc
dump_bash_state() { :; }
export -f dump_bash_state 2>/dev/null
- 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
- 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
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?
Opposite problem: agents ignore all other config and use a zsh subprocess instead of my desired shell.
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.
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:
-
@cyotee (Sep 17) - Reported identical
dump_zsh_stateparse error with shell integration enabled -
@gleruzh (Sep 29) - Found that disabling shell integration fixes it:
"terminal.integrated.shellIntegration.enabled": false -
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_statefunction with a no-op - β
Uses standard ANSI escape sequences (
precmd/preexec) instead of Cursor's broken injection - β
Only affects Cursor terminals (via
$CURSOR_TRACE_IDdetection) - β 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:
- Switching to standard ANSI escape sequences (what this fix implements)
- Or fixing the shell integration script injection logic
- Or providing a built-in way to disable just
dump_zsh_statewithout disabling all shell integration
The stub approach demonstrates it's fixable at the user level, suggesting the code path is discoverable.