Skip to content

Powershell extension never completes initializing... #4720

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
6 tasks done
benpxs opened this issue Sep 4, 2023 · 13 comments
Closed
6 tasks done

Powershell extension never completes initializing... #4720

benpxs opened this issue Sep 4, 2023 · 13 comments
Labels
Area-Startup Issue-Bug A bug to squash. Needs: Author Feedback Please give us the requested feedback!

Comments

@benpxs
Copy link

benpxs commented Sep 4, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

When starting a intergrated terminal session the extension never finishes initializing. I can use powershell outside of this terminal but without intellisense/formatting etc.

The terminial info 'hover' window shows:
PowerShell Extension

Process ID (PID): 16672

Command line: C:\Program Files\PowerShell\7\pwsh.exe '-NoProfile' '-ExecutionPolicy' 'Bypass' '-Command' 'Import-Module 'c:\Users<user>.vscode\extensions\ms-vscode.powershell-2023.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users<user>.vscode\extensions\ms-vscode.powershell-2023.6.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.6.0 Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell Type 'help' to get help. " -LogLevel 'Normal' -LogPath 'c:\Users<user>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1693824471-40f1424a-a573-4b8a-bfc7-992a1b203df51693824469438\EditorServices.log' -SessionDetailsPath 'c:\Users<user>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-25696-773225.json' -FeatureFlags @() '

The following extensions have contributed to this terminal's environment:

Git: Enables the following features: git auth provider`

The terminal output log for the extension only shows:
`9/4/2023 12:47:51 PM [NORMAL] - Visual Studio Code: v1.81.1 64-bit on Windows 64-bit

9/4/2023 12:47:51 PM [NORMAL] - PowerShell Extension: v2023.6.0

9/4/2023 12:47:52 PM [NORMAL] - Starting 'PowerShell_7' at: C:\Program Files\PowerShell\7\pwsh.exe

9/4/2023 12:47:54 PM [NORMAL] - PowerShell process started with PID: 16672`

Powershell editor outputlog:
`[Warn - 12:52:56 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.RequestCancelled | @request='OmniSharp.Extensions.JsonRpc.RequestCancelled'

I have settings synced to a different PC and it works fine there. I have uninstalled the extension, including in the .vscode folder
I see the pid is running, but it seems that the extension never 'gets told' about it, or that some other extension process is starting/hung.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.81.1
6c3e3dba23e8fadc360aed75ce363ba185c49794
x64

Extension Version

Steps to Reproduce

  1. Open vs code (standard/non-admin user)
  2. Open a powershell script
  3. wait...

Visuals

image
image
image

Logs

When the terminal is closed the terminal output is shows:
9/4/2023 1:14:31 PM [VERBOSE] - Loaded settings:
{
"powerShellAdditionalExePaths": {
"PowerShell_7": "C:\Program Files\PowerShell\7\pwsh.exe",
"PowerShell": "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
},
"powerShellDefaultVersion": "PowerShell_7",
"powerShellExePath": "",
"promptToUpdatePowerShell": true,
"startAsLoginShell": {
"osx": true,
"linux": false
},
"startAutomatically": true,
"enableProfileLoading": true,
"helpCompletion": "BlockComment",
"scriptAnalysis": {
"enable": true,
"settingsPath": "PSScriptAnalyzerSettings.psd1"
},
"debugging": {
"createTemporaryIntegratedConsole": false
},
"developer": {
"featureFlags": [],
"bundledModulesPath": "../../PowerShellEditorServices/module",
"editorServicesLogLevel": "Diagnostic",
"editorServicesWaitForDebugger": false,
"waitForSessionFileTimeoutSeconds": 240
},
"codeFormatting": {
"autoCorrectAliases": true,
"avoidSemicolonsAsLineTerminators": false,
"preset": "Custom",
"openBraceOnSameLine": true,
"newLineAfterOpenBrace": true,
"newLineAfterCloseBrace": true,
"pipelineIndentationStyle": "NoIndentation",
"whitespaceBeforeOpenBrace": true,
"whitespaceBeforeOpenParen": true,
"whitespaceAroundOperator": true,
"whitespaceAfterSeparator": true,
"whitespaceBetweenParameters": false,
"whitespaceInsideBrace": true,
"addWhitespaceAroundPipe": true,
"trimWhitespaceAroundPipe": true,
"ignoreOneLineBlock": true,
"alignPropertyValuePairs": true,
"useConstantStrings": false,
"useCorrectCasing": false
},
"integratedConsole": {
"showOnStartup": true,
"startInBackground": false,
"focusConsoleOnExecute": true,
"useLegacyReadLine": false,
"forceClearScrollbackBuffer": false,
"suppressStartupBanner": false
},
"sideBar": {
"CommandExplorerVisibility": true,
"CommandExplorerExcludeFilter": []
},
"pester": {
"useLegacyCodeLens": true,
"outputVerbosity": "FromPreference",
"debugOutputVerbosity": "Diagnostic"
},
"buttons": {
"showRunButtons": true,
"showPanelMovementButtons": false
},
"cwd": "c:\Dev\VSC\Repos++Projects++\project\project",
"enableReferencesCodeLens": true,
"analyzeOpenDocumentsOnly": false
}

9/4/2023 1:14:31 PM [VERBOSE] - Creating log directory at: 'file:///c%3A/Users//AppData/Roaming/Code/User/globalStorage/ms-vscode.powershell/logs/1693826071-b016fe0c-aa75-41a2-8566-d3244cdae8c61693826024286'

9/4/2023 1:14:31 PM [NORMAL] - Visual Studio Code: v1.81.1 64-bit on Windows 64-bit

9/4/2023 1:14:31 PM [NORMAL] - PowerShell Extension: v2023.6.0

9/4/2023 1:14:31 PM [VERBOSE] - Session status changing from 'Not Started' to 'Starting'.

9/4/2023 1:14:31 PM [VERBOSE] - Finding PowerShell...

9/4/2023 1:14:31 PM [NORMAL] - Starting 'PowerShell_7' at: C:\Program Files\PowerShell\7\pwsh.exe

9/4/2023 1:14:31 PM [VERBOSE] - Starting process: C:\Program Files\PowerShell\7\pwsh.exe -NoProfile -ExecutionPolicy Bypass -Command Import-Module 'c:\Users.vscode\extensions\ms-vscode.powershell-2023.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users.vscode\extensions\ms-vscode.powershell-2023.6.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.6.0
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Diagnostic' -LogPath 'c:\Users\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1693826071-b016fe0c-aa75-41a2-8566-d3244cdae8c61693826024286\EditorServices.log' -SessionDetailsPath 'c:\Users\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-29264-104885.json' -FeatureFlags @()

9/4/2023 1:14:32 PM [NORMAL] - PowerShell process started with PID: 29800

9/4/2023 1:14:32 PM [VERBOSE] - Waiting for session file: file:///c%3A/Users//AppData/Roaming/Code/User/globalStorage/ms-vscode.powershell/sessions/PSES-VSCode-29264-104885.json

9/4/2023 1:14:33 PM [VERBOSE] - Session file found.

9/4/2023 1:14:33 PM [VERBOSE] - Session details: {
"status": "started",
"languageServiceTransport": "NamedPipe",
"languageServicePipeName": "\.\pipe\PSES_mclz1pls.f3n",
"debugServiceTransport": "NamedPipe",
"debugServicePipeName": "\.\pipe\PSES_uy1w1z3b.a2z",
"powerShellVersion": "7.3.6"
}

9/4/2023 1:14:33 PM [VERBOSE] - Connecting to language service...

9/4/2023 1:14:33 PM [VERBOSE] - Language service connected.

9/4/2023 1:26:40 PM [WARNING] - PowerShell process terminated or Extension Terminal was closed, PID: 29800

9/4/2023 1:26:41 PM [ERROR] - Never finished startup!

@benpxs benpxs added the Issue-Bug A bug to squash. label Sep 4, 2023
@SydneyhSmith
Copy link
Collaborator

Thanks @benpxs and thanks for providing the detailed log info-- super helpful!
It seems stuck in LanguageClient.Start which we don't implement, but we are going to try and add more logging around it to get more info since we can't reproduce....

Have you ever had success with the extension or have you always hit this issue?

@andyleejordan
Copy link
Member

andyleejordan commented Sep 6, 2023

@benpxs do you have the rest of the PowerShell Editor Services log (the one with the warning about "Tried to send request or notification before initialization was completed and will be sent later"), or any of the JSON payload?
Link to get those.

As far as I can tell it is stuck in the call to the LSP client library's start function...which we don't implement, it comes from the VS Code library. So I'm trying to figure out what else might be going on.

@andyleejordan
Copy link
Member

Also, we have a theory that perhaps it's stuck loading your profiles. You could confirm this for us pretty easily by trying to repro with the extension setting powershell.enableProfileLoading set to false.

@andyleejordan andyleejordan moved this from Todo to In Progress in Flying Fox Sep 6, 2023
@benpxs
Copy link
Author

benpxs commented Sep 7, 2023

Thanks for the replies all.
@SydneyhSmith: Yes it was working when I installed it - I do remember playing with profiles, but they didn't work the way I expected (and not havng enough time to check the reason properly), so I abandoned it. I thought I had reset everything...I think it may have been the time this stopped working, but it was some time ago and I can't be sure.

@andyleejordan : setting powershell.enableProfileLoading to false didn't change the behaviour...the logs you referred to don't exist (i had looked already). The full output you mentioned says:

[Warn - 8:29:15 AM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.RequestCancelled | @request='OmniSharp.Extensions.JsonRpc.RequestCancelled'
[Error - 8:30:09 AM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 8:30:09 AM] Connection to PowerShell Editor Services (the Extension Terminal) was closed. See below prompt to restart!
[Error - 8:30:09 AM] PowerShell Editor Services client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097

If you need the JSON payload, I'll need a bit of help in finding that?

@andyleejordan andyleejordan moved this from In Progress to Todo in Flying Fox Sep 8, 2023
@andyleejordan
Copy link
Member

@benpxs have you been able to teste this with the pre-release extension? Here's a more direct link to the section about getting the JSON payload: https://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md#provide-language-server-protocol-payload-logs, it's under "Provide Language Server Protocol payload logs." Thanks!

@andyleejordan
Copy link
Member

Another question: do you have oh-my-posh or anything similar enabled? That seems to cause problems because of the handlers it adds to PSReadLine.

@andyleejordan andyleejordan added the Needs: Author Feedback Please give us the requested feedback! label Nov 10, 2023
@andyleejordan andyleejordan moved this from Todo to Wishlist in Flying Fox Nov 10, 2023
@benpxs
Copy link
Author

benpxs commented Nov 13, 2023

@andyleejordan - nope, no other PS related add-on enabled. I have settings sync configured and my other (home) pc it works just fine (its a new build). I've tried removing the extension, the files and so (even vsc), but no mater what I delete, it remains in the same state (I guess I am missing something I should delete).

@github-actions github-actions bot added the Stale label Nov 16, 2023
Copy link
Contributor

This issue has been labeled as needing feedback and has not had any activity for one or more weeks. It has been closed for housekeeping purposes.

@github-project-automation github-project-automation bot moved this from Wishlist to Done in Flying Fox Nov 21, 2023
@twirlse
Copy link

twirlse commented Nov 28, 2023

I was having the same issues, and after playing with the settings, I came to the conclusion that the issue is somehow related to using a custom PowerShell installation folder. I'm using Scoop as a package manager, and PowerShell 7 is installed with it. In my VSCode config, I set pwsh as the default terminal with a custom path, like this:

  "terminal.integrated.profiles.windows": {
    "PowerShell 7": {
      "path": "${env:userprofile}\\scoop\\apps\\pwsh\\current\\pwsh.exe"
    }
  }

If I add a custom PowerShell exe path and select it as the default PowerShell version, the extension starts working again. Something like this:

  "powershell.powerShellAdditionalExePaths": {
    "pwsh": "c:\\Users\\<username>\\scoop\\apps\\pwsh\\current\\pwsh.exe"
  },
  "powershell.powerShellDefaultVersion": "pwsh"

Previously, it was working without these modifications, but I'm just happy it works now. :)

@andyleejordan
Copy link
Member

@andyleejordan - nope, no other PS related add-on enabled. I have settings sync configured and my other (home) pc it works just fine (its a new build). I've tried removing the extension, the files and so (even vsc), but no mater what I delete, it remains in the same state (I guess I am missing something I should delete).

No idea why the bot messed up there, but question: are you using the Windows Store installed PowerShell?

@andyleejordan andyleejordan reopened this Nov 29, 2023
@andyleejordan andyleejordan moved this from Done to In Progress in Flying Fox Nov 29, 2023
@github-actions github-actions bot added the Stale label Dec 1, 2023
Copy link
Contributor

github-actions bot commented Dec 7, 2023

This issue has been labeled as needing feedback and has not had any activity for one or more weeks. It has been closed for housekeeping purposes.

@github-actions github-actions bot closed this as completed Dec 7, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Flying Fox Dec 7, 2023
@peterlobster
Copy link

peterlobster commented Jun 18, 2024

Another question: do you have oh-my-posh or anything similar enabled? That seems to cause problems because of the handlers it adds to PSReadLine.

@andyleejordan What if you are using oh-my-posh? Is there a workaround? I tried disabling loading my profile, but it seems to have the issue still. I also updated PSReadline, which made everything way faster, but the issue still exists.

@andyleejordan
Copy link
Member

@peterlobster could you open a new issue and go through the template's steps of adding logs so we can help you better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Startup Issue-Bug A bug to squash. Needs: Author Feedback Please give us the requested feedback!
Projects
Status: Done
Development

No branches or pull requests

5 participants