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.

SDK resolver does not work with snap installations of SDK on Linux

See original GitHub issue

See https://github.com/OmniSharp/omnisharp-vscode/issues/3160

When installed via snap:

sudo snap install dotnet-sdk --beta --classic
sudo snap alias dotnet-sdk.dotnet dotnet

Then dotnet on PATH resolves to a realpath of /usr/bin/snap and not to a dotnet executable next to the sdk foler.

This breaks an assumption of the resolver that we can use realpath on dotnet on PATH to find the SDK.

We could maybe implement something like the much slower option of shelling out to dotnet --info as msbuildlocator and legacy omnisharp do. Or we would need a way to resolve to the real directory somehow. I am not sure if snap gives us this ability. Is there a way to query snap to know if there is a dotnet-sdk installed and where can we find it’s real directory. Can we do this without forking processes and parsing stdout?

The slow path could be a fallback. If there is a dotnet on PATH, but it does not resolve to a realpath with an sdk directory, try running it with --info. This would fix other hypothetical deployments like a dotnet that is a shell script that execs dotnet with custom args or whatever. It may make sense to keep this as an ultimate fallback even if we find a more efficient way to handle the snap case.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:37 (14 by maintainers)

github_iconTop GitHub Comments

50reactions
mattiaswernercommented, Apr 29, 2020

I was struggling with omnisharp not resolving the dotnet-sdk snap on 20.04 until I discovered that a simple

ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet

did the trick. No need for msbuild path exports or an omnisharp json legacy resolver.

3reactions
gp200918commented, Oct 2, 2020

DO NOT USE Ubuntu. Not even the Binary file from https://dotnet.microsoft.com/download/dotnet/5.0 works because the dotnet executable is not recognized on Ubuntu. I guess it is related to dotnet-sdk on snap on Ubuntu.

I have no problems using the .net5 RC1 on Fedora 33 beta.

Download the dotnet-sdk SDK manually. I have downloaded the Binaries from https://dotnet.microsoft.com/download/dotnet/5.0 No package manager.

Start VSCode with a script file with this content: export PATH=$PATH:/YYY/ /home/XXX/Downloads/VSCode/code-insiders

where you have to adapt XXX and YYY to your case. YYY is the folder where you have stored the SDK.

DO NOT USE Ubuntu snap. Someone working on snap dotnet-sdk must have introduced an automatic “dotnet” alias that is listed but can not be removed with the “sudo snap unalias dotnet” command because Error: “cannot find manual alias “dotnet” in any snap”. Unfortunately the people working on omnisharp do not care about this problem.

From my console:

xxx:~$ dotnet

Usage: dotnet [options] Usage: dotnet [path-to-application]

Options: -h|–help Display help. –info Display .NET information. –list-sdks Display the installed SDKs. –list-runtimes Display the installed runtimes.

path-to-application: The path to an application .dll file to execute. xxx:~$ snap aliases Befehl Alias Anmerkungen dotnet-sdk.dotnet dotnet - xxx:~$ sudo snap unalias dotnet Fehler: cannot find manual alias “dotnet” in any snap

Previously:

I made this post already here and here.

On Ubuntu 20.04.1, the problem is the snap alias. Do not install it.

Instead do this:

sudo snap install dotnet-sdk --channel=5.0/beta --classic

DO NOT install the alias because it makes Omnisharp not find the SDK. sudo snap alias dotnet-sdk.dotnet dotnet

It can be removed with: sudo snap unalias dotnet

Start VSCode with a script file with this content: export PATH=$PATH:/snap/dotnet-sdk/current/ /home/XXX/Downloads/VSCode/code-insiders

You have to adapt the second line, that starts VSCode insiders, to your case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet sdk is installed but not recognized - Linux Ubuntu ...
Here is what happens when I try to do an apt install of the sdk(It shows already installed): sudo apt install dotnet-sdk-6.0 [sudo]...
Read more >
Why don't any of these methods work for installing .Net ...
Install .NET SDK 6.0. sudo apt update sudo apt install dotnet-sdk-6.0 ... The following simple command has fixed the problem for me:
Read more >
Ubuntu: resolve dotnet-sdk snap `command 'dotnet' not found`
I'm trying to install and run dotnet-sdk on Ubuntu but after I run sudo snap install dotnet-sdk , I keep getting the error...
Read more >
Install the .NET SDK or the .NET Runtime on Ubuntu
Demonstrates the various ways to install .NET SDK and .NET Runtime on Ubuntu.
Read more >
Problem with my snap download : r/ManjaroLinux
Hi there! When I want to Install a snap package I usually got this message. But only a few package, sometimes I can...
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