Skip to content

Unable to start PowerShell extension on Windows without PS 6+ installed #2217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mohammedha opened this issue Sep 30, 2019 · 22 comments · Fixed by #2238
Closed

Unable to start PowerShell extension on Windows without PS 6+ installed #2217

mohammedha opened this issue Sep 30, 2019 · 22 comments · Fixed by #2238
Labels

Comments

@mohammedha
Copy link

mohammedha commented Sep 30, 2019

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 -v
1.38.1
b37e54c98e1a74ba89e03073e5a3761284e3ffb0
x64

> $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

@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 30, 2019
@TylerLeonhardt
Copy link
Member

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

@TylerLeonhardt TylerLeonhardt added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Sep 30, 2019
@mohammedha
Copy link
Author

uploaded to the original post

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 30, 2019
@TylerLeonhardt
Copy link
Member

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?

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 30, 2019
@Bummibaer
Copy link

Bummibaer commented Oct 1, 2019

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:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
1.10.2019 10:45:51 [NORMAL] - args: c:\Users\foo.vscode\extensions\ms-vscode.powershell-2019.9.0\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\ADNetz.vscode\extensions\ms-vscode.powershell-2019.9.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\ADNetz.vscode\extensions\ms-vscode.powershell-2019.9.0\logs\1569919551-b833b993-4e56-4bc7-9a8f-cf4bec56ec0a1569919463806\EditorServices.log' -SessionDetailsPath 'c:\Users\ADNetz.vscode\extensions\ms-vscode.powershell-2019.9.0\sessions\PSES-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 \.\pipe\PSES_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...

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 1, 2019
@mohammedha
Copy link
Author

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

@TylerLeonhardt
Copy link
Member

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

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 1, 2019
@mohammedha
Copy link
Author

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 2, 2019
@TylerLeonhardt
Copy link
Member

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

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 2, 2019
@OranguTech
Copy link

OranguTech commented Oct 3, 2019

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]

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 3, 2019
@OranguTech
Copy link

OranguTech commented Oct 3, 2019

@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?

@rjmholt
Copy link
Contributor

rjmholt commented Oct 3, 2019

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

@mohammedha
Copy link
Author

@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

@OranguTech
Copy link

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.

@rjmholt
Copy link
Contributor

rjmholt commented Oct 3, 2019

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

@rjmholt rjmholt changed the title Unable to instantiate; language client undefined. Unable to start PowerShell extension on Windows without PS 6+ installed Oct 10, 2019
@ghost ghost added the Status: In PR label Oct 10, 2019
@SylvainMartel
Copy link

SylvainMartel commented Oct 23, 2019

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 23, 2019
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 23, 2019
@ghost
Copy link

ghost commented Oct 26, 2019

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.

[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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 26, 2019
@TylerLeonhardt
Copy link
Member

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

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 28, 2019
@ghost ghost added Status: Fixed and removed Status: In PR labels Oct 29, 2019
@tonipohl
Copy link

tonipohl commented Mar 8, 2020

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 8, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 17, 2020
@af4jm
Copy link

af4jm commented Sep 3, 2020

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 3, 2020
@Mayhem93
Copy link

Mayhem93 commented Sep 29, 2020

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.

@rjmholt
Copy link
Contributor

rjmholt commented Sep 29, 2020

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.

@Mayhem93
Copy link

Mayhem93 commented Sep 29, 2020

@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.

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
10 participants