Skip to content

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

Closed
@nguerrera

Description

@nguerrera

See dotnet/vscode-csharp#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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions