Skip to content

The language service could not be started (PowerShell Global Tool) #2620

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
Countryen opened this issue Apr 8, 2020 · 13 comments
Closed

The language service could not be started (PowerShell Global Tool) #2620

Countryen opened this issue Apr 8, 2020 · 13 comments
Assignees
Labels
Resolution-External Will close automatically.

Comments

@Countryen
Copy link

System Details

System Details Output

PS C:\Users\Pascal Ried> & {"### VSCode version: $(code -v)"; "`n### VSCode extensions:`n$(code --list-extensions --show-versions | Out-String)"; "`n### PSES version: $($pseditor.EditorServicesVersion)"; "`n### PowerShell version:`n$($PSVersionTable | Out-String)"}

### VSCode version: 1.44.0 2aae1f26c72891c399f860409176fe435a154b13 x64

### VSCode extensions:
74th.Theme-NaturalContrast-With-HC@1.0.0  
aeschli.vscode-css-formatter@1.0.1        
akamud.vscode-theme-onedark@2.2.1
ardencod3.The-Orange-Box-Theme@1.0.0      
bceskavich.theme-dracula-at-night@2.6.0   
benjaminkott.typo3-typoscript@0.2.0       
EditorConfig.EditorConfig@0.14.5
EhsanAnsari.sakura-garden-at-night@1.0.1  
esbenp.prettier-vscode@4.1.1
eugeneoneill.combinedcasts@0.0.4
fabiospampinato.vscode-monokai-night@1.6.0
febley.typo3-fluid-snippets@0.3.1
febley.typo3-vhs-snippets@0.1.1
felixfbecker.php-intellisense@2.3.14
gerane.Theme-krTheme@0.0.5
gerane.Theme-Monokai-Contrast@0.0.5
gerane.Theme-Monokai-Midnight@0.0.5
gerane.Theme-TomorrowNightBright@0.0.5
handsomeone.8bit@0.1.3
jigsaw5279.typoscript@0.0.2
k--kato.docomment@0.1.9
kokororin.vscode-phpfmt@1.0.30
mikaelkristiansson87.react-theme-vscode@1.0.4
ms-azuretools.vscode-azurefunctions@0.22.0
MS-CEINTL.vscode-language-pack-de@1.44.2
ms-dotnettools.csharp@1.21.16
ms-python.python@2020.3.71659
ms-vscode.azure-account@0.8.9
ms-vscode.powershell@2020.3.0
ralffreit.typo3snippets@0.1.0
redhat.java@0.59.1
shinnn.stylelint@0.50.0
SirTori.indenticator@0.6.0
VisualStudioExptTeam.vscodeintellicode@1.2.6
vscjava.vscode-java-debug@0.25.1
vscjava.vscode-java-dependency@0.9.0
vscjava.vscode-java-pack@0.8.1
vscjava.vscode-java-test@0.22.3
vscjava.vscode-maven@0.21.2


### PSES version: 2.0.0.0

### PowerShell version:

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

Issue Description

Same problem as for #2119 and #1360 and #1957 and others.

Don't know when it started but PowerShell failed to work for me and doing what's said in issue #2119 did not help. I've fixed the problem now manually with changes to settings.json (see below my workaround). I wanted to share my solution here.

Problem: "The language service could not be started" and no support for PS in VS Code.
Additionally, every time I start VS this red message appears very shortly (like for half a second) in a terminal inside VSC (in German):
image

Get-ExecutionPolicy is set to Bypass (no difference when setting it to Default, either).

Executing suggested Import-Module $HOME\.vscode\extensions\ms-vscode.powershell*\modules\PowerShellEditorServices\PowerShellEditorServices.psd1 does nothing (no question, no output, nothing).

I've now installed PS7 (.NET Core version), thinking maybe it fixes the problem - doesn't fix it.
Trying the same command (Import-Module...) with PS7 - nothing different.

When using >PowerShell: Show Session Menu I see the following:
image

I then select Switch to: Windows PowerShell (x64) and that seems to fix my problem as now the mentioned question about the "untrustworthy code" shows up and after saying [A] to it, everything works as expected.

Only problem now, PS7 is not used but I really want to use the new PS7.
The "Session Menu" now shows:
image

I then select "Switch to: .NET Core PowerShell Global Tool" and it fails again (with the same red error message and the same error logs as described in the other issue #2119).

Here's my workaround for PS7 to work:
Adding the following to the settings.json, in my case C:\Users\Pascal Ried\AppData\Roaming\Code\User\settings.json to

"terminal.integrated.shell.windows": "P:\\IDE\\PowerShell\\7\\pwsh.exe",
  "powershell.powerShellDefaultVersion": "Windows PowerShell (x64)",
  "powershell.powerShellAdditionalExePaths": [
    {
      "versionName": "PowerShell 7",
      "exePath": "P:\\IDE\\PowerShell\\7\\pwsh.exe"
    }
  ],

and then selecting "Switch to: PowerShell 7" in the Session Menu.

Maybe this helps someone (or future me) with the same problem.
Basically I think there is a problem with the "Global Tool" but don't know much more.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Apr 8, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Apr 9, 2020

@Countryen did you see #2158?

@SydneyhSmith
Copy link
Collaborator

@Countryen thanks for the detailed explanation, how did you download "P:\\IDE\\PowerShell\\7\\pwsh.exe" this is helpful in us determining if the issue is being caused by the Global tool or happening for all versions of PS7...thanks!

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Apr 9, 2020
@Countryen
Copy link
Author

@SydneyhSmith The issue was before using "P:\\IDE\\PowerShell\\7\\pwsh.exe" but I've downloaded it from here:

https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0
PowerShell-7.0.0-win-x64.msi

I don't know how I've got the "Global Tool".

@rjmholt No but thanks for the link. I didn't know there are "dotnet global tools" before this issue.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 11, 2020
@Countryen
Copy link
Author

Just FYI: The red error translates to something like:

Execution not possible because file or command not found.
Possible reasons:

  • You have misspelled an integrated dotnet-command.
  • You wanted to execute a .net core program but dotnet-C:\Users\Pascal doesn't exist.
  • You wanted to execute a global tool but in PATH is no executable file with the prefix dotnet.

Note that C:\Users\Pascal Ried\ is my actual user profile folder, although I am quite sure it was just C:\Users\pascal\ not long ago (did Windows change that?)

Maybe the space in my username causes problems because it doesn't show up in the error message fully?

@rjmholt rjmholt self-assigned this Apr 14, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Apr 14, 2020

So it looks like:

The PowerShell extension does its best to pick PowerShell up from well known installation paths, but won't find custom installations, so installing through the MSI to a custom path will mean you need to configure the extension to pick up your custom install as you've done.

The initial load failure seems to be a combination of picking up the .NET global tool first by default (which the extension will do when it doesn't find a PowerShell 7 installation elsewhere and no default version is set) and the dotnet global tool startup failing for some reason.

If you're able to share your extension logs, we might be able to work out what the invocation is that's failing when the extension tries to start the global tool.

@Countryen
Copy link
Author

Here's the log for the successful use of my "custom installation":

14.4.2020 23:40:05 [NORMAL] -     PowerShell executable: P:\IDE\PowerShell\7\pwsh.exe
14.4.2020 23:40:05 [NORMAL] -     PowerShell Editor Services args: Import-Module 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1586900405-d23742bc-a522-4cca-8b6a-470b8eefc5381586900384672\EditorServices.log' -SessionDetailsPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-3616-280673' -FeatureFlags @() 
14.4.2020 23:40:05 [NORMAL] - Waiting for session file
14.4.2020 23:40:05 [NORMAL] - Language server starting --
14.4.2020 23:40:05 [NORMAL] - pwsh.exe started.
14.4.2020 23:40:05 [NORMAL] -     PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1586900405-d23742bc-a522-4cca-8b6a-470b8eefc5381586900384672\EditorServices.log' -SessionDetailsPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-3616-280673' -FeatureFlags @() 
14.4.2020 23:40:07 [NORMAL] - Session file found
14.4.2020 23:40:07 [NORMAL] - Registering terminal PID log callback
14.4.2020 23:40:07 [NORMAL] - Registering terminal close callback
14.4.2020 23:40:07 [NORMAL] - pwsh.exe PID: 17788
14.4.2020 23:40:07 [NORMAL] - {"status":"started","languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_guydqevm.nri","debugServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_5ty1vrdf.fp1"}
14.4.2020 23:40:07 [NORMAL] - Language server started.
14.4.2020 23:40:07 [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_guydqevm.nri...
14.4.2020 23:40:07 [NORMAL] - Language service connected.
14.4.2020 23:40:24 [NORMAL] - Shutting down language client...
14.4.2020 23:40:24 [NORMAL] - Terminating PowerShell process...

And here is the one failing:

15.4.2020 00:00:04 [NORMAL] - Language server starting --
15.4.2020 00:00:04 [NORMAL] -     PowerShell executable: C:\Users\Pascal Ried\.dotnet\tools\pwsh.exe
15.4.2020 00:00:04 [NORMAL] -     PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1586901604-d40a0912-8104-4e0b-bbe8-8feb792c69cd1586901373985\EditorServices.log' -SessionDetailsPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-1512-409846' -FeatureFlags @() 
15.4.2020 00:00:04 [NORMAL] -     PowerShell Editor Services args: Import-Module 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1586901604-d40a0912-8104-4e0b-bbe8-8feb792c69cd1586901373985\EditorServices.log' -SessionDetailsPath 'c:\Users\Pascal Ried\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-1512-409846' -FeatureFlags @() 
15.4.2020 00:00:04 [NORMAL] - pwsh.exe started.
15.4.2020 00:00:04 [NORMAL] - Waiting for session file
15.4.2020 00:02:04 [NORMAL] - Error occurred retrieving session file
15.4.2020 00:02:04 [NORMAL] - Language server startup failed.
15.4.2020 00:02:04 [ERROR] - The language service could not be started: 
15.4.2020 00:02:04 [ERROR] - Timed out waiting for session file to appear.

See the attachment for the output from the "PowerShell Editor Services" when failing
ps-editor-services-log.txt

Hope that's correct, this is my settings file:

  "powershell.developer.editorServicesLogLevel": "Diagnostic",
  "powershell editor services.trace.server":"verbose"
}

@rjmholt
Copy link
Contributor

rjmholt commented Apr 15, 2020

Thanks for that!

Would you be able to run this from PowerShell and respond with the result:

& 'C:\Users\Pascal Ried\.dotnet\tools\pwsh.exe' -c '$PSVersionTable'

@Countryen
Copy link
Author

Same "red error" message:
image
(same in PowerShell and PowerShell 7)

@rjmholt
Copy link
Contributor

rjmholt commented Apr 15, 2020

Ok that's a good sign that there's an issue with the actual dotnet global tool here. Are you able to start the executable with & 'C:\Users\Pascal Ried\.dotnet\tools\pwsh.exe'? If so, what's the output of $PSVersionTable within that PowerShell?

@Countryen
Copy link
Author

No, can't start the pwsh.exe with that command, same error message.
I can, however, start the pwsh.exe with this line of commands:

cd 'C:\Users\Pascal Ried\.dotnet\tools\'
& "pwsh.exe" -c '$PSVersionTable'

Output:

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

@rjmholt
Copy link
Contributor

rjmholt commented Apr 15, 2020

That's very odd. From my machine:

> & 'C:\Users\Robert Holt\.dotnet\tools\pwsh.exe' -c '$PSVersionTable'

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

I wonder if this is a bug in your particular dotnet version. It might be worth updating it to see if that changes anything.

@rjmholt
Copy link
Contributor

rjmholt commented Apr 15, 2020

Otherwise, if you don't want the global tool, I'd recommend uninstalling it, since you already have an MSI installation

@Countryen
Copy link
Author

Okay, it works now after running

dotnet tool uninstall powershell --global
dotnet tool install powershell --global

PS C:\Users\Pascal Ried> & "C:\Users\Pascal Ried\.dotnet\tools\pwsh.exe" -c '$PSVersionTable'

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

Note: I did not update dotnet or anything else, yet.

Why? No idea but I guess it was a weird bug that's resolved by a complete reinstall of the dotnet global tool.
Thanks for the help.

@rjmholt rjmholt closed this as completed Apr 16, 2020
@TylerLeonhardt TylerLeonhardt added Resolution-External Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-External Will close automatically.
Projects
None yet
Development

No branches or pull requests

4 participants