I am experiencing a problem with starting a new powershell core session installed as a dotnet global tool.
When starting a new session (or restarting session) the following command is run (I had to forward through a .bat file to see the full command line):
pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "& 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PowerShellEditorServices\Start-EditorServices.ps1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.5.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\logs\1567006029-f7cca153-6746-4776-870d-c91b50d994961567005382269\EditorServices.log' -SessionDetailsPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\sessions\PSES-VSCode-14016-656222' -FeatureFlags @()"
This command line fails with current error (pasted just the first few lines):
At line:1 char:190
+ ... \PowerShellEditorServices\Start-EditorServices.ps1' -HostName 'Visual ...
+ ~~~~~~~~~
Unexpected token '-HostName' in expression or statement.
At line:1 char:200
+ ... Start-EditorServices.ps1' -HostName 'Visual Studio Code Host' -HostPr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token ''Visual Studio Code Host'' in expression or statement.
At line:1 char:226
+ ... vices.ps1' -HostName 'Visual Studio Code Host' -HostProfileId 'Micros ...
2019-08-28 12:47:26 p.m. [NORMAL] - Language server starting --
2019-08-28 12:47:26 p.m. [NORMAL] - exe: C:\users\fqborges\.dotnet\tools\pwsh.exe
2019-08-28 12:47:26 p.m. [NORMAL] - args: C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.5.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\logs\1567007246-b6fb03e1-293e-44cf-906b-3133006b191d1567007152041\EditorServices.log' -SessionDetailsPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\sessions\PSES-VSCode-14016-910739' -FeatureFlags @()
2019-08-28 12:47:27 p.m. [NORMAL] - powershell.exe started, pid: 14520
2019-08-28 12:47:28 p.m. [NORMAL] - powershell.exe terminated or terminal UI was closed
To make sure this is not an error related to the default terminal or encoding or something I crated an "custom powershell" that is just the windows powershell 64 forward through a bat file, and it worked.
settings.json related lines
"powershell.powerShellAdditionalExePaths": [
{
"exePath": "C:\\git\\powershell\\cmd.bat",
"versionName": "bat"
},
{
"exePath": "C:/users/fqborges/.dotnet/tools/pwsh.exe",
"versionName": "dotnet pwsh"
},
],
cmd.bat
C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe %*
terminal content on starting session
C:\git\powershell>C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "& 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\mo
dules\PowerShellEditorServices\Start-EditorServices.ps1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.5.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -Bundle
dModulesPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\logs\1567
007559-b6fb03e1-293e-44cf-906b-3133006b191d1567007152041\EditorServices.log' -SessionDetailsPath 'C:\Users\fqborges\.vscode\extensions\ms-vscode.powershell-2019.5.0\sessions\PSES-VSCode-14016-600106' -FeatureFlags
@()"
PowerShell Integrated Console
PS C:\git\powershell>
PS C:\git\powershell>
| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.17763 |
| VSCode | 1.37.1|
| PowerShell Extension Version | 2019.5.0 |
PowerShell 6.2.2 installed as dotnet core tool
dotnet tool install --global PowerShell
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version|
|---|---|---|
|csharp|ms-vscode|1.21.1|
|powershell|ms-vscode|2019.5.0|
|prettier-vscode|esbenp|2.2.2|
|vscode-docker|ms-azuretools|0.7.0|
|vscode-sql-beautify|sensourceinc|0.0.4|
|vscode-typescript-tslint-plugin|ms-vscode|1.2.2|
|xml|DotJoshJohnson|2.5.0|
@fqborges thanks for reporting this issue...this actually comes from a bug in the dot net tool where it makes certain assumptions about the environment commands are run in...we are tracking the bug in the dot net tool here https://github.com/PowerShell/PowerShell/issues/10355
We are also tracking the request to have the dot net global tool file path picked up automatically by the extension here: #2110 --that issue will likely get addressed once the underlying bug in the global tool is fixed
Closing as Resolved by a fix with the Global Tool
Most helpful comment
@fqborges thanks for reporting this issue...this actually comes from a bug in the dot net tool where it makes certain assumptions about the environment commands are run in...we are tracking the bug in the dot net tool here https://github.com/PowerShell/PowerShell/issues/10355
We are also tracking the request to have the dot net global tool file path picked up automatically by the extension here: #2110 --that issue will likely get addressed once the underlying bug in the global tool is fixed