.NET SDK not found if installed via Snap and Snap aliases used
See original GitHub issueIssue Description
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.
Steps to Reproduce
- Run Ubuntu 18.04
sudo snap install dotnet-sdk --classic
sudo snap install code --classic
- In VS Code, install the C# Extension
Expected Behavior
OmniSharp runs dotnet --info
and finds the .NET SDK correctly.
Actual Behavior
.NET SDK is not found because dotnet --info
exists with a SIGABRT.
Logs
OmniSharp log
(empty)
C# log
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
Stack trace generated by Gdb
#0 0x00007f888b78fe97 in raise () from /snap/dotnet-sdk/38/lib/x86_64-linux-gnu/libc.so.6 #1 0x00007f888b791801 in abort () from /snap/dotnet-sdk/38/lib/x86_64-linux-gnu/libc.so.6 #2 0x00007f888ae8fa23 in PROCAbort () from /snap/dotnet-sdk/38/shared/Microsoft.NETCore.App/2.2.5/libcoreclr.so #3 0x00007f888ae8e81b in PROCEndProcess(void*, unsigned int, int) () from /snap/dotnet-sdk/38/shared/Microsoft.NETCore.App/2.2.5/libcoreclr.so #4 0x00007f888abf7938 in UnwindManagedExceptionPass1(PAL_SEHException&, _CONTEXT*) () from /snap/dotnet-sdk/38/shared/Microsoft.NETCore.App/2.2.5/libcoreclr.so #5 0x00007f888abf7ab3 in DispatchManagedException(PAL_SEHException&, bool) () from /snap/dotnet-sdk/38/shared/Microsoft.NETCore.App/2.2.5/libcoreclr.so #6 0x00007f888ab7464a in IL_Throw(Object*) () from /snap/dotnet-sdk/38/shared/Microsoft.NETCore.App/2.2.5/libcoreclr.so #7 0x00007f8812469928 in ?? () #8 0x0000000d00010002 in ?? () #9 0x0000000d00010002 in ?? () #10 0x0000000000000000 in ?? ()
Environment information
VSCode version: 1.34.0 C# Extension: 1.19.1
Mono Information
OmniSharp using global mono :5.20.1Dotnet 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: 8757db13ecRuntime 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 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5 (2 by maintainers)
Top GitHub Comments
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.