Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
PowerShell Execution Error in Cursor IDE - String Escaping Bug
Summary
All PowerShell commands fail to execute in Cursor IDE due to a string escaping bug in the temporary script generation. The error occurs at line 34, character 134 of the generated temporary PowerShell scripts.
Environment
- OS: Windows 10 (Build 22621)
- Cursor IDE Version: (Please check your version)
- PowerShell Version: (Please check with
$PSVersionTable)
Problem Description
When executing any PowerShell command in Cursor IDE, the following error occurs:
所在位置 C:\Users\Administrator\AppData\Local\Temp\ps-script-*.ps1:34 字符: 134
+ ... coding]::UTF8.GetString([System.Convert]::FromBase64String(''{1}''))) ...
~
方法调用中缺少")"。
Root Cause
Cursor IDE generates temporary PowerShell scripts with incorrect string escaping. The issue is:
-
String Escaping Error:
- Generated code:
FromBase64String(''{1}'') - Problem: Single quotes are escaped as
'', but the string contains format placeholders{1} - In PowerShell, single quotes inside single-quoted strings need to be escaped as
'', but this conflicts with format placeholders
- Generated code:
-
String Formatting Issue:
- Generated code:
'Set-Alias -Name "{0}" -Value "{1}"' - Problem: Format placeholders
{0}and{1}are used inside single-quoted strings, which are literals in PowerShell and don’t support variable expansion or formatting
- Generated code:
Error Details
Error Type: ParserError
Error ID: MissingEndParenthesisInMethodCall
Error Location: Temporary script file line 34, character 134
Full Error Message:
所在位置 ...\ps-script-*.ps1:34 字符: 134
+ ... coding]::UTF8.GetString([System.Convert]::FromBase64String(''{1}''))) ...
~
方法调用中缺少")"。
所在位置 ...\ps-script-*.ps1:34 字符: 134
+ ... oding]::UTF8.GetString([System.Convert]::FromBase64String(''{1}'')))' ...
~
表达式或语句中包含意外的标记"{"
所在位置 ...\ps-script-*.ps1:49 字符: 20
+ Emit ('Set-Alias -Name "{0}" -Value "{1}"' -f $alias.Name ...
~~~~~~~~~
表达式或语句中包含意外的标记"Set-Alias"
Steps to Reproduce
- Open Cursor IDE
- Try to execute any PowerShell command (e.g.,
echo "test",$PSVersionTable, etc.) - All commands fail with the same parsing error
Expected Behavior
PowerShell commands should execute successfully, as they do in external PowerShell windows.
Actual Behavior
All PowerShell commands fail with parsing errors due to incorrect string escaping in the generated temporary scripts.
Workaround
- Use external PowerShell windows
- Use batch files (.bat) for command execution
- Use CMD terminal instead of PowerShell
Technical Details
Incorrect Script Generation Logic
The bug appears to be in how Cursor IDE escapes strings when generating temporary scripts:
# Current (incorrect) behavior:
$command = "FromBase64String('{1}')"
$escaped = $command -replace "'", "''" # Wrong: escapes all single quotes
# Result: FromBase64String(''{1}'') ❌
Correct Approach
Should use one of the following:
# Option 1: Use double quotes
$command = "FromBase64String(`"{1}`")"
# Option 2: Use backtick escaping
$command = "FromBase64String('`{1`}')"
# Option 3: Use Here-String
$command = @"
FromBase64String('{1}')
"@
Additional Notes
- Encoding issues were initially suspected but have been resolved (PowerShell profile configured for UTF-8)
- The error messages are now readable in Chinese, confirming encoding is not the issue
- The core problem is the string escaping logic in script generation
Request
Please fix the string escaping logic in the temporary PowerShell script generation to properly handle strings containing format placeholders and special characters.
Note: This bug affects all PowerShell command execution in Cursor IDE on Windows. It’s a critical issue that prevents users from using PowerShell commands within the IDE.
Steps to Reproduce
Steps to Reproduce
- Open Cursor IDE on Windows
- Open the integrated terminal (View → Terminal, or press
Ctrl+`) - Ensure PowerShell is selected as the terminal shell (should show
PSprompt) - Try to execute any PowerShell command, for example:
echo "test"$PSVersionTableGet-DateWrite-Host "Hello"- Any other PowerShell command
- Observe the error: All commands fail with the same parsing error about missing closing parenthesis at line 34, character 134 of the temporary script file
Note: The same commands work perfectly fine when executed in an external PowerShell window outside of Cursor IDE.
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
Version: 2.2.14 (system setup)
VSCode Version: 1.105.1
Commit: 1685afce45886aa5579025ac7e077fc3d4369c50
Date: 2025-12-11T01:12:35.790Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.22621
Does this stop you from using Cursor
Yes - Cursor is unusable