Skip to content

Can't load native libraries on Pop!_OS #2461

@WNP78

Description

@WNP78

Summary

Silk.NET seems to have some native dependency resolving logic that fails to find the correct folder in runtimes/ on Pop!_OS 22.04.

Steps to reproduce

  • Platform: Desktop, Pop!_OS 22.04 LTS, .NET SDK 9.0.106
  • Framework Version: targetting .NET 8.0
  • API: SDL (but probably the rest too, that's just the first failure)
  1. Try to import/use SDL from Silk.NET (just GetApi() is enough to trigger it)
  2. Run program with dotnet run

Comments

Running the program with strace indicates that the paths being searched are bin/Debug/net8.0/runtimes/pop.22.04-x64/native/libSDL2-2.0.so, followed by a bunch of system library paths. Obviously, the actual library it should be finding is in runtimes/linux-x64 and not runtimes/pop.22.04-x64.

I looked into the logic for selecting this path and it seems that this RID is coming from Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier, in two places:

var currentRid = RuntimeEnvironment.GetRuntimeIdentifier();

and

foreach (var rid in GetAllRuntimeIds(RuntimeEnvironment.GetRuntimeIdentifier(), DependencyContext.Default))

I saw inside Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier that this can be overridden by an environment variable, so I tested by setting export DOTNET_RUNTIME_ID=linux-x64 and this did allow packages to load, but this isn't really a "proper" solution.

I saw here that this package is removed from newer versions and on NuGet it seems to not have been updated in almost 5 years.

I also tested and found it gave a different result to the built-in API:

> Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
"pop.22.04-x64"
> System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier            
"ubuntu.22.04-x64"

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions