Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Bug Report: Agent Shell floods “Add-Content: Stream was not readable” errors on Chinese Windows
Cursor Version
- Version: 2.6.11 (system setup)
- VSCode Version: 1.105.1
- Commit: 8c95649f251a168cc4bb34c89531fae7db4bd990
- Date: 2026-03-03T18:57:48.001Z
- Electron: 39.6.0
- Node.js: 22.22.0
Operating System
Windows_NT x64 10.0.19044 (Chinese Simplified, Code Page 936/GBK)
Steps to Reproduce
- Use Cursor on a Chinese Windows system (system locale: Chinese Simplified, code page 936)
- Start a new Agent chat session
- Ask Agent to run any shell command, e.g.,
echo testorpython --version
Expected Behavior
The command output should be displayed cleanly without errors.
Actual Behavior
Every shell command execution produces massive Add-Content : Stream was not readable errors:
Add-Content : 流不可读。
所在位置 C:\Users\Administrator\AppData\Local\Temp\ps-script-xxx.ps1:19 字符: 9
+ Add-Content -Path $OutputFile -Value $Content -Encoding UTF8
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (...txt:String) [Add-Content], ArgumentException
+ FullyQualifiedErrorId : GetContentWriterArgumentError,Microsoft.PowerShell.Commands.AddContentCommand
This error repeats dozens or hundreds of times per command, flooding the output. The actual command usually still executes successfully (exit code 0), but the output is buried in errors.
Root Cause Analysis
- Cursor Agent Shell generates temporary PowerShell scripts (
ps-script-xxx.ps1) in%TEMP% - These scripts use
Add-Content -Path $OutputFile -Value $Content -Encoding UTF8to capture output - The
-Encoding UTF8parameter conflicts with the default GBK/GB2312 encoding on Chinese Windows (code page 936) - This causes “Stream was not readable” errors
Environment Details
| Item | Value |
|---|---|
| System Code Page (ACP/OEMCP) | 936 (GBK) |
| PowerShell Version | 5.1.19041.1682 |
[Console]::OutputEncoding |
GB2312 (default) |
| PowerShell Profile | Not present (all 4 locations) |
What I’ve Tried (None Worked)
1. VS Code Terminal Settings:
"terminal.integrated.automationProfile.windows": {
"path": "C:\\Windows\\System32\\cmd.exe"
},
"terminal.integrated.defaultProfile.windows": "Command Prompt"
Result: No effect on Agent Shell (it uses its own execution mechanism)
2. PowerShell UTF-8 Configuration:
# PowerShell Profile
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
Add-Content -Path $PROFILE -Value '[Console]::OutputEncoding = [System.Text.Encodin
g]::UTF8'
# Python UTF-8 environment variables [Environment]::SetEnvironmentVariable("PYTHONUTF8", "1", "Machine") [Environment]::SetEnvironmentVariable("PYTHONIOENCODING", "utf-8", "Machine")
# System locale
setx LANG zh_CN.UTF-8
Result: No effect on Agent Shell
3. System Reboot:
Result: Issue is intermittent - sometimes disappears after reboot, but comes back later
Additional Notes
- This issue is intermittent - sometimes the errors appear, sometimes they don’t, with no clear pattern
- User commands in Cursor’s integrated terminal work fine - only Agent Shell is affected
- The command itself usually executes successfully; errors are just noise
Suggested Fix
Consider using -Encoding Default instead of -Encoding UTF8 in the generated PowerShell scripts, or detect the system encoding and use an appropriate value.
Steps to Reproduce
- Use Cursor on a Chinese Windows system (system locale: Chinese Simplified, code page 936)
- Start a new Agent chat session
- Ask Agent to run any shell command, e.g.,
echo testorpython --version
Operating System
Windows 10/11
Version Information
- Version: 2.6.11 (system setup)
- VSCode Version: 1.105.1
- Commit: 8c95649f251a168cc4bb34c89531fae7db4bd990
- Date: 2026-03-03T18:57:48.001Z
- Electron: 39.6.0
Does this stop you from using Cursor
No - Cursor works, but with this issue