If the .NET SDK has been installed via Snap (sudo snap install dotnet-sdk) on Ubuntu 18.04, and a Snap alias has been created with sudo snap alias dotnet-sdk.dotnet dotnet as recommended in https://github.com/dotnet/core-setup/issues/4230#issuecomment-398841315, then OmniSharp can't find the .NET SDK because dotnet --info fails with a SIGABRT when run from inside VS Code. Interestingly, dotnet --info works just fine when run from the command line.
Workaround: If instead of creating a Snap alias, I set my PATH to include /snap/dotnet-sdk/current somewhere before /snap/bin, then the dotnet --info command works and OmniSharp can find the .NET SDK as it should.
If I enable core dumps in Ubuntu, I can get a stack trace from the core dump. Unfortunately, the Snap package for dotnet-sdk does not appear to include debugging symbols so the stack trace isn't very useful, but I've included it in the Logs section below anyway.
sudo snap install dotnet-sdk --classicsudo snap install code --classicOmniSharp runs dotnet --info and finds the .NET SDK correctly.
.NET SDK is not found because dotnet --info exists with a SIGABRT.
(empty)
Platform: linux, x86_64, name=ubuntu, version=18.04
Downloading package 'OmniSharp for Linux (x64)' (43145 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Linux (x64)'
Downloading package '.NET Core Debugger (linux / x64)' (64083 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (linux / x64)'
Downloading package 'Razor Language Server (Linux / x64)' (58328 KB).................... Done!
Installing package 'Razor Language Server (Linux / x64)'
Finished
Failed to spawn 'dotnet --info'
Stack trace generated by Gdb
VSCode version: 1.34.0
C# Extension: 1.19.1
Mono Information
OmniSharp using global mono :5.20.1
Dotnet Information (actual)
A valid dotnet installation could not be found.
Dotnet Information (expected)
.NET Core SDK (reflecting any global.json):
Version: 2.2.204
Commit: 8757db13ec
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /snap/dotnet-sdk/38/sdk/2.2.204/
Host (useful for support):
Version: 2.2.5
Commit: 0a3c9209c0
.NET Core SDKs installed:
2.2.204 [/snap/dotnet-sdk/38/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.5 [/snap/dotnet-sdk/38/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.5 [/snap/dotnet-sdk/38/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.5 [/snap/dotnet-sdk/38/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|csharp|ms-vscode|1.19.1|
|csharpextensions|jchannon|1.3.0|
|docomment|k--kato|0.1.7|
|Ionide-FAKE|Ionide|1.2.3|
|Ionide-fsharp|Ionide|3.37.0|
|Ionide-Paket|Ionide|1.12.0|
|msbuild-project-tools|tintoy|0.2.54|
|vscode-versionlens|pflannery|0.23.0|;
@rmunn this isn't an issue with the C# extension, though I am not sure what I would suggest you do with this issue. If you run dotnet --info from a VS Code terminal, do you get anything more helpful?
If I run dotnet --info from the VS Code terminal, it works, and I get the expected output (which I included in the issue description under "Dotnet Information (expected)" in case it's useful). The only failure scenario I've been able to reproduce is for OmniSharp to be launching the dotnet --info command during VS Code startup.
I'm also not sure where the root cause of this bug lies; if I could figure out what exception is being thrown in IL_Throw from libcoreclr.so, I might have better luck putting this in the right place. But since the only time I can reproduce this bug is when OmniSharp is involved, I figure here is as good a place for the issue to live as any, at least until I can track down the cause better.
Have the same issue. After running "sudo snap alias dotnet-sdk.dotnet dotnet" dotnet --info works fine in a terminal, but I still get:
Failed to spawn 'dotnet --info'
from "C# for Visual Studio Code (powered by OmniSharp)."
For a quick fix creating a symlink at /usr/local/bin/dotnet seems to solve the issue.
sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet
I am going to close this issue since it isn't really about this extension. Note that I am adding a help link to the error message with #3507 which has specific troubleshooting steps for Snap.
Most helpful comment
For a quick fix creating a symlink at
/usr/local/bin/dotnetseems to solve the issue.sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet