【CURSOR】run command,打开powershell失败,C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe ‘-l‘
但问题是,每次都是运行失败,报错C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe ‘-l’ exit with code -1。低版本的powershell(默认是5)接收这个参数会报错,最新版本的powershell(最新版本是7)才可以兼容这个参数。这个参数在bash、zsh等这类linux或unix的shell里是有效参数,代
问题描述
CURSOR,在AI的回复里有时候会有一些命令,可以直接点run command 来运行,而不用自己copy到终端运行。但问题是,每次都是运行失败,报错C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe ‘-l’ exit with code -1。
原因分析
其实是因为Cursor在打开powershell终端时默认添加了不该添加的参数“-l”,也就是-login的意思。
这个参数在bash、zsh等这类linux或unix的shell里是有效参数,代表使用当前登录用户的配置,但是对powershell无效。
低版本的powershell(默认是5)接收这个参数会报错,最新版本的powershell(最新版本是7)才可以兼容这个参数。显然,Cursor的开发团队没有在低版本的powershell上测试过。
解决方法
更新到 PowerShell 7.5 (latest stable version)。以管理员身份运行powershell并升级:
winget install --id Microsoft.PowerShell --source winget
如果命令行升级失败,可以自己去官网安装升级powershell。
升级后,验证版本,在powershell 7中运行:
$PSVersionTable # Check version info, should show 7.5.0
注意,5版本的powershell运行命令就是powershell,而7版本改成了pwsh。
重启vscode或cursor,可以看到新建的terminal已经自动切换到了pwsh。
参考
https://forum.cursor.com/t/terminal-fails-in-composer-on-windows-powershell-exit-code-1/37130/9
更多推荐


所有评论(0)