Skip to content

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

Closed

Description

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

Activity

  1. ghost added
    Needs: Triage
    on Sep 30, 2019
  2. TylerLeonhardt commented on Sep 30, 2019

    @TylerLeonhardt
    Member

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

  3. added and removed
    Needs: Triage
    on Sep 30, 2019
  4. mohammedha commented on Sep 30, 2019

    @mohammedha
    Author

    uploaded to the original post

  5. ghost added
    Needs: Maintainer Attention
    on Sep 30, 2019
  6. TylerLeonhardt commented on Sep 30, 2019

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

  7. Bummibaer commented on Oct 1, 2019

    @Bummibaer

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

  8. ghost added
    Needs: Maintainer Attention
    on Oct 1, 2019
  9. mohammedha commented on Oct 1, 2019

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

  10. TylerLeonhardt commented on Oct 1, 2019

    @TylerLeonhardt
    Member

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

  11. removed
    Needs: Maintainer Attention
    on Oct 1, 2019
  12. mohammedha commented on Oct 2, 2019

    @mohammedha
    Author

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

  13. ghost added
    Needs: Maintainer Attention
    on Oct 2, 2019
  14. 21 remaining items

  15. TylerLeonhardt commented on Oct 26, 2019

    @TylerLeonhardt
    Member

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

  16. tonipohl commented on Mar 8, 2020

    @tonipohl

    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

  17. ghost added
    Needs: Maintainer Attention
    on Mar 8, 2020
  18. af4jm commented on Sep 3, 2020

    @af4jm

    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.

  19. ghost added
    Needs: Maintainer Attention
    on Sep 3, 2020
  20. Mayhem93 commented on Sep 29, 2020

    @Mayhem93

    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.

  21. rjmholt commented on Sep 29, 2020

    @rjmholt
    Contributor

    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.

  22. Mayhem93 commented on Sep 29, 2020

    @Mayhem93

    Rob Holt (@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-StartupIssue-Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions