question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET SDK not found if installed via Snap and Snap aliases used

See original GitHub issue

Issue 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

  1. Run Ubuntu 18.04
  2. sudo snap install dotnet-sdk --classic
  3. sudo snap install code --classic
  4. 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

Installing C# dependencies... 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

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.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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

35reactions
nelsontkqcommented, Jun 4, 2019

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

0reactions
gregg-miskellycommented, Jan 14, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install .NET on Linux with Snap - Microsoft Learn
Demonstrates how to install either the .NET SDK or the .NET Runtime on Linux with Snap.
Read more >
How To Configure an Alias for The .NET SDK Snap
The issue with this new command structure is that all scripts and tooling will expect the command to be named exactly like the...
Read more >
`dotnet` command not found after installing using snap
You should try the following command. sudo snap alias dotnet-sdk.dotnet dotnet. Since snap doesn't provide automatic aliases for dotnet-sdk ...
Read more >
Requesting automatic alias for dotnet - store - snapcraft.io
Hey folks, Have been working with Sergio &c at the rally in NYC to snap .NET Core. There is an SDK and Runtime...
Read more >
Install the .NET SDK or the .NET Runtime with Snap - YouTube
NET Runtime with Snap - just a small video to demo installation of . NET core using snap for Ubuntu system.for more, visit:https:/......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found