Skip to content
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

LSP server launched by extension can't find installed .NET runtime #5734

Closed
swythan opened this issue Jun 8, 2023 · 5 comments
Closed

LSP server launched by extension can't find installed .NET runtime #5734

swythan opened this issue Jun 8, 2023 · 5 comments
Assignees
Milestone

Comments

@swythan
Copy link

swythan commented Jun 8, 2023

Environment data

dotnet --info output:

dotnet --info
.NET SDK:
 Version:   7.0.302
 Commit:    990cf98a27

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.302/

Host:
  Version:      7.0.5
  Architecture: x64
  Commit:       8042d61b17

.NET SDKs installed:
  3.1.426 [/usr/share/dotnet/sdk]
  5.0.408 [/usr/share/dotnet/sdk]
  6.0.300 [/usr/share/dotnet/sdk]
  7.0.302 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.16 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

VS Code version:

Version: 1.78.2 (system setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No

C# Extension version:

ms-dotnettools.csdevkit@0.1.83
ms-dotnettools.csharp@2.0.206
ms-dotnettools.vscode-dotnet-runtime@1.6.0

OmniSharp log

Dotnet path: /usr/bin/dotnet
Activating C# standalone...
You must install .NET to run this application.

App: /home/admin/.vscode-server/extensions/ms-dotnettools.csharp-2.0.206/.roslyn/Microsoft.CodeAnalysis.LanguageServer
Architecture: x64
App host version: 7.0.0-preview.7.22362.8
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.22.04-x64&apphost_version=7.0.0-preview.7.22362.8
[Info  - 12:39:51] Connection to server got closed. Server will restart.
[Error - 12:39:51] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 12:39:51] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

Steps to reproduce

  1. Be on a network that is not connected to the internet
  2. Install .NET SDKs & VSCode on Windows machine
  3. Create a Linux k8s pod that has .NET SDKs installed from the Ubuntu repo
  4. Manually install extensions on Windows machine (win-x64 versions)
  5. Manually install VS code remote server and C# extensions on Linux k8s pod (linux-x64 versions)
  6. Configure both to not hit the internet to download the .NET runtime
    • Windows
       "dotnetAcquisitionExtension.existingDotnetPath": [  
         {"extensionId": "ms-dotnettools.vscode-dotnet-runtime", "path": "C:\\Program Files\\dotnet\\dotnet.exe"},
         {"extensionId": "ms-dotnettools.csharp", "path": "C:\\Program Files\\dotnet\\dotnet.exe"},
         {"extensionId": "ms-dotnettools.csdevkit", "path": "C:\\Program Files\\dotnet\\dotnet.exe"},
         {"extensionId": "ms-dotnettools.vscodeintellicode-csharp", "path": "C:\\Program Files\\dotnet\\dotnet.exe"},
       ],
    • Linux
       "dotnetAcquisitionExtension.existingDotnetPath": [  
         {"extensionId": "ms-dotnettools.vscode-dotnet-runtime", "path": "/usr/bin/dotnet"},
         {"extensionId": "ms-dotnettools.csharp", "path": "/usr/bin/dotnet"},
         {"extensionId": "ms-dotnettools.csdevkit", "path": "/usr/bin/dotnet"},
         {"extensionId": "ms-dotnettools.vscodeintellicode-csharp", "path": "/usr/bin/dotnet"},
       ],
  7. Use Remote-ssh to connect VSCode from Windows to linux/k8s
  8. Open a C# file

Expected behavior

The Language Server should start correctly (using the installed .NET runtime) and C# features should work in the editor.

Actual behavior

The language server fails to start, as shown above.

Dotnet path: /usr/bin/dotnet
Activating C# standalone...
You must install .NET to run this application.

App: /home/admin/.vscode-server/extensions/ms-dotnettools.csharp-2.0.206/.roslyn/Microsoft.CodeAnalysis.LanguageServer
Architecture: x64
App host version: 7.0.0-preview.7.22362.8
.NET location: Not found

Additional context

Running the same language server executable from a VS Code Terminal pane works fine:

admin@delta:~/git/delta$ /home/admin/.vscode-server/extensions/ms-dotnettools.csharp-2.0.206/.roslyn/Microsoft.CodeAnalysis.LanguageServer --version
4.7.0-2.23272.9+2244596ee0a1e757ab57881db33829123b6d1da8

With the C# Dev Kit installed I see the same behaviour there, except App host version in the log is 7.0.5.

@Igorgro
Copy link

Igorgro commented Jun 8, 2023

Having the same problem: I've installed .NET runtime and sdk using dotnet-install.sh script, added it to PATH and even set vscode settings to point to existing installation, but this extension still tries to download its own runtime

@dibarbet
Copy link
Member

dibarbet commented Jun 8, 2023

Can you check if the environment variable DOTNET_ROOT is set? If not, does setting it to the installed dotnet location work?
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86

@dibarbet dibarbet added this to the GA milestone Jun 8, 2023
@Igorgro
Copy link

Igorgro commented Jun 8, 2023

Yes, setting DOTNET_ROOT helped for me

@swythan
Copy link
Author

swythan commented Jun 10, 2023

Thanks.

It seems like something has gone wrong with the way the .NET runtime is installed on our Ubuntu docker image amd /etc/dotnet/install_location was missing. Setting that up correctly worked ofr me.

See:
dotnet/runtime#79237
dotnet/core#7699

@swythan swythan closed this as completed Jun 10, 2023
@exyi
Copy link

exyi commented Aug 19, 2023

I have a very similar problem, but neither DOTNET_ROOT or /etc/dotnet/install_location resolve the issue for me. Interestingly, when I execute ~/.vscode/extensions/ms-dotnettools.csharp-2.0.376-linux-x64/.roslyn/Microsoft.CodeAnalysis.LanguageServer from the terminal, it starts up.

My workaround is to set "dotnet.server.useOmnisharp": true

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

No branches or pull requests

5 participants