`RuntimesFolderResolver` fails on Ubuntu
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 477
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
# 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](https://github.com/dotnet/Silk.NET/blob/266259d37/src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs#L370-L374):
```csharp
private static readonly string[] _linuxRiDs =
{
"alpine", "android", "arch", "centos", "debian", "exherbo", "fedora", "freebsd", "gentoo", "linux",
"opensuse", "rhel", "sles", "tizen", "pop"
};
```
[`GuessFallbackRid`](https://github.com/dotnet/Silk.NET/blob/266259d37/src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs#L399) 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](https://github.com/dotnet/Silk.NET/blob/266259d37/src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs#L394-L397)) that doesn't depend on this list.
### Reproduction
```bash
# 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`
Contributor guide
Assessment
This issue has not been assessed yet.