Cursor can't execute some commands in mac

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The agent cannot execute certain commands. When the command is executed, it immediately fails with a return code of -1. This does not happen with all commands; it generally occurs with pipes and sequential executions. For example, while the “go version” command works, the “cd ~/Projects/test && go version” command does not. The agent keeps adding “cd” to the beginning of commands, so it cannot execute any commands and behaves erratically.

Steps to Reproduce

When I open the Cursor, I tell the agent to run the command “cd ~/Projects/test && go version” and I get this error again.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.3.41
VSCode Version: 1.105.1
Commit: 2ca326e0d1ce10956aea33d54c0e2d8c13c58a30
Date: 2026-01-16T19:14:00.150Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 24.6.0

Additional Information

For my zshrc configuration, I add configurations below, but the behaviour does not change.

# ~/.zshrc — disable Powerlevel10k when Cursor Agent runs
if [[ -n "$CURSOR_AGENT" ]]; then
  # Skip theme initialization for better compatibility
else
  [[ -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
fi

also

# ~/.zshrc — disable Powerlevel10k when Cursor Agent runs
if [[ -n "$CURSOR_AGENT" ]]; then
  # Skip theme initialization for better compatibility
else
  [[ -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
fi

and

if  [[ -n "$CURSOR_AGENT" ]]; then
else
  if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
    source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
  fi
fi

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, this is a known issue with how the agent sandbox handles zsh builtins, especially the cd command. It gets turned into an autoload function without a real definition file, so chained commands with && fail.

A couple workarounds:

  1. Disable the sandbox:
    Cursor Settings > Agents > Auto-Run, set it to “Ask Every Time”, then click Run or add it to the allowlist

  2. Legacy Terminal Tool:

  • Cursor Settings Cmd+Shift+J > Agents > Inline Editing & Terminal
  • Turn on “Legacy Terminal Tool”
  • Cmd+Shift+P > “Terminal: Kill All Terminals”
  • Fully restart Cursor

The team knows about this issue and is working on a fix. Your report helps with visibility.

The first option does not work. But I turned on “Legacy Terminal Tool”. It’s now working. Thanks

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.