microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.81k stars 28.74k forks source link

Launching built-in pwsh.exe crashes terminal toolbar #201367

Closed Zydnar closed 8 months ago

Zydnar commented 9 months ago

Type: Bug image

I get following error:

-noexit : The term ’-noexit’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:l char:l
+ -noexit -command try { . c:\Program Files\Microsoft VS Code Insiders\ ...
+ Categoryinfo  : ObjectNotFound: (-noexit:String) [], CommandNotFoundException
+ FullyQualifiedErrorld : CommandNotFoundException

then bottom toolbar with terminal crashes. When I quickly switch to CMD instead of pwsh and inside CMD I launch powershell all works just fine. I was searching for -noexit using following command in Visual Studio Code installation directory: Get-ChildItem -Recurse -Filter *.* | Select-String -Pattern "noexit" and all occurences are somewhere in resources\app\out\vs and subfolders. I don't want to edit these files manually.

VS Code version: Code - Insiders 1.86.0-insider (37fe2d06d65db4b50303c5f5e8ca589a50f2287a, 2023-12-15T05:36:59.071Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2904)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.91GB (5.51GB free)| |Process Argv|--crash-reporter-id 5f2b9313-ed07-4d2e-9af2-b9d50ff09326| |Screen Reader|no| |VM|67%|
Extensions (32) Extension|Author (truncated)|Version ---|---|--- vscode-gcode-syntax|app|0.7.7 doxdocgen|csc|1.4.0 better-cpp-syntax|jef|1.17.2 papyrus-lang-vscode|joe|3.2.0 vs-color-picker|lih|1.0.0 nc-gcode|ML|0.13.0 vscode-docker|ms-|1.28.0 vscode-language-pack-pl|MS-|1.85.2023121309 python|ms-|2023.22.1 vscode-pylance|ms-|2023.12.1 jupyter|ms-|2023.11.1003402403 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.327.0 cmake-tools|ms-|1.16.32 cpptools|ms-|1.19.1 cpptools-extension-pack|ms-|1.3.0 hexeditor|ms-|1.9.12 vscode-serial-monitor|ms-|0.11.0 platformio-ide|pla|3.3.1 java|red|1.25.1 rust-analyzer|rus|0.4.1777 cmake|twx|0.0.17 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.2.30 vscode-arduino|vsc|0.6.0 vscode-gradle|vsc|3.13.5 vscode-java-debug|vsc|0.55.0 vscode-java-dependency|vsc|0.23.3 vscode-java-pack|vsc|0.25.15 vscode-java-test|vsc|0.40.1 vscode-maven|vsc|0.43.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythontb:30258533 pythonptprofiler:30281269 vshan820:30294714 vscod805cf:30301675 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30404738 py29gd2263:30784851 vsclangdf:30492506 c4g48928:30535728 dsvsc012:30540252 a9j8j154:30646983 showlangstatbar:30737417 fixshowwlkth:30771523 showindicator:30805243 pythongtdpath:30726887 i26e3531:30792625 welcomedialog:30812478 pythonidxpt:30768918 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 pythonmpswarning:30901777 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30926734 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 aa_t_chat:30882232 cp7184c:30925681 ```
Zydnar commented 9 months ago

I updated to: Version: 1.86.0-insider (system setup) Commit: 9621add46007f7a1ab37d1fce9bcdcecca62aeb0 Date: 2023-12-20T05:36:57.756Z Electron: 27.1.3 ElectronBuildId: 25612240 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Windows_NT x64 10.0.19045 issue persists. I was searching for a solution and it's not like noexit is wrong param but though it's named it's required to place it in specific order, see: https://stackoverflow.com/questions/38831008/start-powershell-with-noexit-not-working

meganrogge commented 8 months ago

not clear what's happening - are you using -NoExit as an argument to your terminal profile?

Zydnar commented 8 months ago

@meganrogge Terminal profile? Is it something beyond Visual Studio Code files? If yes, no that I'm aware of it, how can I check it? Most of apps I've installed through Chocolatey tool and I rather use defaults everywhere. If no, I had the issue before even I started editing launch.json or profile.json.

Zydnar commented 8 months ago

@meganrogge The only thing that comes to mind is the powershell itself - I see this:

PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

when launching pwsh and this:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

when launching powershell.

meganrogge commented 8 months ago

does disabling shell integration fix it IE terminal.shellIntegration.enabled: false?

Zydnar commented 8 months ago

@meganrogge No. However I just found new information when hovering over terminal on the list before it crashed: image CMD looks more normal: image

Zydnar commented 8 months ago

@meganrogge I think I figured out the issue, you'll decide how to deal with it. VS Code basically does this:

Microsoft Windows [Version 10.0.19045.3803]
(c) Microsoft Corporation. Wszelkie prawa zastrzeżone.

C:\Guidem3>pwsh -noexit '..\Program Files\Microsoft VS Code Insiders\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1'      
-noexit : The term '-noexit' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -noexit '..\Program Files\Microsoft VS Code Insiders\resources\app\ou ...
+ ~~~~~~~
+ CategoryInfo          : ObjectNotFound: (-noexit:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

And as you see it doesn't work at least for PowerShell 6.2.3 or 7.2.8 But if I use:

Microsoft Windows [Version 10.0.19045.3803]
(c) Microsoft Corporation. Wszelkie prawa zastrzeżone.

C:\Guidem3>powershell -noexit '..\Program Files\Microsoft VS Code Insiders\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1' 
..\Program Files\Microsoft VS Code Insiders\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1

it does work with \system32\WindowsPowerShell\v1.0\powershell.exe

meganrogge commented 8 months ago

have you at one point manually enabled shell integration? that's all I can imagine if you're saying that disabling our automatic shell integration does not fix it. https://code.visualstudio.com/docs/terminal/shell-integration

Zydnar commented 8 months ago

@meganrogge "have you at one point manually enabled shell integration" - if it wasn't rhetorical question, I checked both options in settings.json : "terminal.shellIntegration.enabled": false, and "terminal.shellIntegration.enabled": true, which changes literally nothing for the error. I restarted VS Code and even whole system - no change. That's all I know. Since I know how to fix this, I'll solve it at my end, you may close the issue.