Skip to content

RuntimesFolderResolver fails on Ubuntu #2568

Description

@xen2

Summary

RuntimesFolderResolver fails on Ubuntu (and other distros missing from hardcoded _linuxRiDs list)

Problem

DefaultPathResolver.RuntimesFolderResolver fails to find native libraries in runtimes/linux-x64/native/ when running on Ubuntu because ubuntu is missing from the hardcoded _linuxRiDs array:

private static readonly string[] _linuxRiDs =
{
    "alpine", "android", "arch", "centos", "debian", "exherbo", "fedora", "freebsd", "gentoo", "linux",
    "opensuse", "rhel", "sles", "tizen", "pop"
};

GuessFallbackRid uses this list to decide whether to fall back from a distro-specific RID (e.g. ubuntu.24.04-x64) to linux-x64. Since ubuntu is not in the list, the method returns null and the resolver only searches runtimes/ubuntu.24.04-x64/native/ — which doesn't exist — and never reaches runtimes/linux-x64/native/.

Windows is unaffected because win has its own hardcoded fallback path (line 394-397) that doesn't depend on this list.

Reproduction

# On Ubuntu 24.04, build a project referencing Silk.NET.SDL (without -r)
dotnet build

# Run via dotnet vstest
dotnet vstest bin/Debug/net10.0/MyTests.dll
# -> FileNotFoundException: Could not load from any of the possible library names!

The native library exists at runtimes/linux-x64/native/libSDL2-2.0.so but is never found.

Suggested Fixes

Quick fix (fragile): Add missing distros (ubuntu, linuxmint, rocky, ol, amzn, ...) to _linuxRiDs. This will break again for any new distro not in the list.

Robust fix ideas:

if (OperatingSystem.IsLinux())
{
    // Check with linux-x64/x86/arm/arm64 depending on RuntimeInformation.OSArchitecture
}

Environment

  • Silk.NET 2.22.0
  • .NET 10.0
  • Ubuntu 24.04 (RID: ubuntu.24.04-x64)
  • Running via dotnet vstest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions