Vscode-powershell: Unable to start PowerShell extension on Windows without PS 6+ installed

Created on 30 Sep 2019  路  22Comments  路  Source: PowerShell/vscode-powershell

Hi there,

After the the extension upgrade to 2019.9.0, I started to get the following error

30/09/2019 11:02:49 [NORMAL] - Visual Studio Code v1.38.1 64-bit
30/09/2019 11:02:49 [NORMAL] - PowerShell Extension v2019.9.0
30/09/2019 11:02:49 [NORMAL] - Operating System: Windows 64-bit
30/09/2019 11:02:49 [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
30/09/2019 11:03:15 [ERROR] - <ConsoleFeature>: Unable to instantiate; language client undefined.

Installed the previous version 2019.5 and was able to load the integrated terminal and run PS cmdlets

VERBOSE: 
#-- Console Encoding ---------------------------------------------------------
VERBOSE: System.Text.ASCIIEncoding
VERBOSE: 
#-- Updated PSModulePath to: -------------------------------------------------
VERBOSE: C:\Users\mohamed\Documents\WindowsPowerShell\Modules
VERBOSE: C:\Program Files\WindowsPowerShell\Modules
VERBOSE: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
VERBOSE: c:\Users\mohamed\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
VERBOSE: 
#-- Check required modules available -----------------------------------------
VERBOSE: Testing module availability PowerShellGet 
VERBOSE: Populating RepositorySourceLocation property for module PowerShellGet.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2\PSModule.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PowerShellGet.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.4\PSModule.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PowerShellGet.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1'.
VERBOSE: PowerShellGet  found

Versions

> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
> code -v
1.38.1
b37e54c98e1a74ba89e03073e5a3761284e3ffb0
x64



md5-e98be4b4cf684e3e96e0480b80fc1f2a



> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.145
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.145
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

vscode-powershell.log

Area-Startup Issue-Bug

All 22 comments

Thanks for the info! Can you also attach the logs here so we can get a better idea of what's going on?

uploaded to the original post

Can you attach the other log files as well? We're looking for a PowerShellEditorServices log file. Or is that the only file that appears in the directory? Please make sure you've turned on Diagnostic logging:

"powershell.developer.editorServicesLogLevel": "Diagnostic"

Also, this is not a requirement for the extension but I'm wondering - do you have PowerShell 6+ (aka PowerShell Core, aka pwsh) installed on your machine?

I have the same issue, additionaly to the log above, get:
BTW: I'm not allowed to execute unsigned scripts...

1.10.2019 10:45:51 [NORMAL] - Language server starting --
1.10.2019 10:45:51 [NORMAL] - exe: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
1.10.2019 10:45:51 [NORMAL] - args: c:Usersfoo.vscodeextensionsms-vscode.powershell-2019.9.0modulesPowerShellEditorServicesStart-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:UsersADNetz.vscodeextensionsms-vscode.powershell-2019.9.0modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:UsersADNetz.vscodeextensionsms-vscode.powershell-2019.9.0logs1569919551-b833b993-4e56-4bc7-9a8f-cf4bec56ec0a1569919463806EditorServices.log' -SessionDetailsPath 'c:UsersADNetz.vscodeextensionsms-vscode.powershell-2019.9.0sessionsPSES-VSCode-9508-733185' -FeatureFlags @()
1.10.2019 10:45:52 [NORMAL] - powershell.exe started, pid: 17664
1.10.2019 10:45:52 [ERROR] - : Unable to instantiate; language client undefined.
1.10.2019 10:45:53 [NORMAL] - Language server started.
1.10.2019 10:45:53 [NORMAL] - {"languageServiceTransport":"NamedPipe","languageServicePipeName":"\\.\pipe\PSES_engwrsub.1dd","debugServiceTransport":"NamedPipe","status":"started","debugServicePipeName":"\\.\pipe\PSES_zundodvk.chg"}
1.10.2019 10:45:53 [NORMAL] - Connecting to language service on pipe \.pipePSES_engwrsub.1dd...
1.10.2019 10:45:53 [NORMAL] - Language service connected.
1.10.2019 10:46:25 [NORMAL] - Shutting down language client...
1.10.2019 10:46:25 [NORMAL] - Terminating PowerShell process...

Can you attach the other log files as well? We're looking for a PowerShellEditorServices log file. Or is that the only file that appears in the directory? Please make sure you've turned on Diagnostic logging:

"powershell.developer.editorServicesLogLevel": "Diagnostic"

Also, this is not a requirement for the extension but I'm wondering - do you have PowerShell 6+ (aka PowerShell Core, aka pwsh) installed on your machine?

Unfortunately this is the only log file available even the log level is set to Diagnostic
I have PS 5.1.18362.145 only.

2019-10-01_12h28_22

@mohammedha do you work in an environment that is locked down via Group Policy or similar?

@TylerLeonhardt not really, also I am running Code as Admin.

Can you run this in a PowerShell session:

[System.Environment]::OSVersion

I'm curious what version of Windows you're on.

Also, can you do me a favor as a test? I'd like you to installed the latest version of PowerShell to see there's a problem in how we discover what PowerShell's are installed on the system.

You can grab the msi from here:
https://github.com/PowerShell/PowerShell#get-powershell

I'm having same issue as well:

(After trying disabling all over extensions, rebooting, running as admin, and trying the
> Import-Module $HOME\.vscode\extensions\ms-vscode.powershell*\modules\PowerShellEditorServices\PowerShellEditorServices.psd1 dance
)

Machine is domain-joined work machine w/ some restrictions, and CarbonBlack. 馃槩

10/2/2019 5:20:21 PM [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
10/2/2019 5:21:29 PM [ERROR] - <ConsoleFeature>: Unable to instantiate; language client undefined.
10/2/2019 5:21:48 PM [ERROR] - <ConsoleFeature>: Unable to instantiate; language client undefined.
10/2/2019 5:26:57 PM [NORMAL] - Shutting down language client...

Environment Info:

> [System.Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.17763.0 Microsoft Windows NT 10.0.17763.0


C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.592
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.592
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

C:\WINDOWS\system32> code -v
1.38.1
b37e54c98e1a74ba89e03073e5a3761284e3ffb0
x64
C:\WINDOWS\system32> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

@TylerLeonhardt - (re)installing* current release version of 6 fixed it!

image

*I previously had v6 installed but uninstalled a while back as there was no immediate benefit, and 7 is on the way...

This doesn't help me too much though, as I need v5 modules.

So how do I point the PSExtension to the v5 instance of PoSh?

So how do I point the PSExtension to the v5 instance of PoSh?

You should be able to select it when you click on the PowerShell version in the bottom right hand corner

@TylerLeonhardt
my OS version is
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.18362.0 Microsoft Windows NT 10.0.18362.0

Okay, I think you are right, the issue is discovering the PS version
After installing PS 6.2 and installing the latest extension version 2019.9 now it started to work
attached my diagnostic logs

Start-EditorServices-EditorServices.log
vscode-powershell.log
EditorServices.log

So how do I point the PSExtension to the v5 instance of PoSh?

You should be able to select it when you click on the PowerShell version in the bottom right hand corner

Thanks, I forgot about that GUI prompt.

I've verified it also works w/ PoSh 7 (Preview 4), without 6 installed.

After installing PS 6.2 and installing the latest extension version 2019.9 now it started to work
attached my diagnostic logs

Drat! Ok, we shall fix

same problem here. Cannot debug or run powershell DSC scripts anymore

"Cannot debug or run a PowerShell script until the PowerShell session has started. Wait for the PowerShell session to finish starting and try again."

This started to happen after I installed PS 6 Core and then removed it. After reinstalling PS 6 Core it worked again.

same problem here. Cannot debug or run powershell DSC scripts anymore

"Cannot debug or run a PowerShell script until the PowerShell session has started. Wait for the PowerShell session to finish starting and try again."

This started to happen after I installed PS 6 Core and then removed it. After reinstalling PS 6 Core it worked again.

I have same issuse. When I uninstall PowerShell 6 than VSCode can't use F5 key and F8 key run powershell srcipt. When I install PowerShell 6 core it become ok.

ms-vscode.[email protected]
1.39.2
6ab598523be7a800d7f3eb4d92d7ab9a66069390
x64

PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

This is fixed in #2238 just need to finish up that PR and then we'll do a release.

Hi,
I ran into the same issue yesterday, the issue suddenly appeared. I could no longer run PS commands in VSCode with the PS extension, although I tried to reconfigure it properly. My solution was to upgrade PS 6.2.x to PS 7.0. Then it worked again.
dotnet tool update --global PowerShell
Tool 'powershell' was successfully updated from version '6.2.3' to version '7.0.0'.
https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
hth! br, Toni

I've got PowerShell 7.0.3 & getting the same error as kinwolfqc & fekfoq259. Tried tonipohl's suggestion, instantly got a message that 7.0.3 was removed & reinstalled (obviously it wasn't since it finished in less than 1 second). No effect, still can't run or debug pwsh in VSCode, even though I have a pwsh terminal open in VS Code.

Hey, first of all, sorry for commenting on a closed issue but I have something to add.

If you have WSL installed and run VScode in "wsl2 mode" you'll get this error message. I ran the "WSL 2: close connection" command the error of "powershell not found" is fixed. But I find it a bit annoying that I have to do that every time, because sometimes I work only with wsl2 mode of VScode, and sometimes with the "regular" mode in which case pwsh 7 is readily available.

If you install PowerShell on the WSL side, I assume the extension works for you as normal?

It sounds like we could improve the error message when PowerShell isn't found -- I think the only reason we haven't done that is that it's surprisingly rare; PowerShell is always there on Windows, and on other platforms people are unlikely to get the extension without already having installed PowerShell.

@rjmholt After installing wsl2 (and the vscode extension for it), it automatically defaults everything to WSL, that's why I called it a "mode". I only recently started working with wsl2 in vscode.

After removing the wsl2 connection (through the mentioned command):

  • If i open vscode through the start menu, it shows that it's not in the "wsl2 mode".
  • Opening it from a powershell cli is the same
  • Opening vscode from wsl2 makes vscode automatically connect to wsl2 backend

After all this, it seems like vscode doesn't run in "wsl2 mode" anymore automatically, unless it's started from wsl2. These are my findings. It seems like it only does it every time initially after installing the wsl2 thingy.

PS: I dont have and not need pwsh on linux but I use it in windows, so this is my use case.

Was this page helpful?
0 / 5 - 0 ratings