Agent terminal commands stop working. The term '-1' is not recognized

Hi, thanks for reporting an issue with Cursor.

Before you report this, we’d appreciate if you can search this forum to see if this issue has already been reported.

If you have done so, please check this box.
on

Describe the Bug

Sometimes I’ll get the following error message popup, and the agent will fail to run any commands. Attached in screenshots section.

Steps to Reproduce

  1. Use Cursor agent normally
  2. Randomly after sending a message and the AI suggesting a command to run, get the following issue

Expected Behavior

The error message should not happen and the agent should be able to run terminal commands as normal.

Screenshots / Screen Recordings


Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 0.44.5
VSCode Version: 1.93.1
Commit: 1d610252e6812bf33245763f0742a534fd0f1d90
Date: 2024-12-20T00:02:28.554Z
Electron: 30.5.1
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Additional Information

Believe it started happening after version 0.44.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, try the following steps to solve the problem:

  1. Check PowerShell settings: Go to File > Preferences > Settings, find terminal.integrated.shell.windows, and make sure the path to PowerShell is correct.
    2. Update PowerShell: Ensure you have the latest version of PowerShell installed. You can download updates from the official Microsoft website.
    3. Check environment variables: Make sure the PATH environment variable contains the correct path to PowerShell.

Had the same problem, eventually resolved with a combination of:

  1. Remove the following line from settings.json
    “terminal.integrated.defaultProfile.windows”: “PowerShell”,
  2. Update PowerShell to PowerShell 7. See Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
1 Like

It indeed must of been an issue with this line:

"terminal.integrated.defaultProfile.windows": "PowerShell",

I simply went into settings, used the following search query to see all modified terminal settings:

@feature:terminal @modified 

To reset everything back to default, I hovered over each of them and press the :gear: → Reset Setting

No more issues since. Perhaps these modified settings came from when I imported my settings over from VS Code, not sure.

I didn’t upgrade Powershell, so that’s not needed unless you want to. However, I actually ended up upgrading at a later date as the AI likes to use && for multiple commands and this requires Powershell 7.

yea install pwshell 7 and then set default termimal to it