[Linux] runtimes/<rid>/native/ not probed on Ubuntu — _linuxRiDs fallback list missing "ubuntu" (regression of #652)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- csharp, linux
- Lĩnh vực
- operating-systems, tooling
Hướng nghiên cứu
Bắt đầu với src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs, đặc biệt là _linuxRiDs, GuessFallbackRid và GetAllRuntimeIds. Tái hiện vấn đề bằng một bản build Ubuntu framework-dependent, sau đó xác minh rằng resolver truy cập được runtimes/linux-x64/native/ và Silk.NET.Windowing.Window.Create thành công mà không cần RuntimeIdentifier hoặc cài đặt GLFW trên hệ thống.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
On Ubuntu / Ubuntu-derived distros, Silk.NET 2.22.0's native loader does not probe runtimes/<rid>/native/ for bundled native libraries because the hardcoded _linuxRiDs fallback list in DefaultPathResolver.cs is missing "ubuntu".
The bundled libglfw.so.3 shipped by the Silk.NET NuGet package is therefore unreachable, and Silk.NET.Windowing.Window.Create(...) throws:
System.PlatformNotSupportedException: Couldn't find a suitable window platform.
(GlfwPlatform - not applicable)
at Silk.NET.Windowing.Window.Create(WindowOptions options)
This is the same symptom as #652 (which #661 was supposed to fix). The RuntimesFolderResolver / NativePackageResolver machinery added in #661 is still there in 2.22.0, but it can't reach linux-x64 from ubuntu.24.04-x64 on a modern .NET SDK because of the missing fallback entry.
Environment
- Silk.NET: 2.22.0
- OS: Pop!_OS 24.04 LTS (Ubuntu-based), kernel 6.18.7, x86_64
- .NET SDK: 10.0.107
- Session: Wayland (with XWayland;
DISPLAY=:1) - Build: framework-dependent
dotnet build(no<RuntimeIdentifier>set, nodotnet publish) RuntimeEnvironment.GetRuntimeIdentifier()reports:ubuntu.24.04-x64
Root cause (traced through the v2.22.0 source)
In src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs:
private static readonly string[] _linuxRiDs =
{
"alpine", "android", "arch", "centos", "debian", "exherbo", "fedora", "freebsd", "gentoo", "linux",
"opensuse", "rhel", "sles", "tizen"
};
GuessFallbackRid("ubuntu.24.04-x64") splits on - giving split[0] = "ubuntu.24.04", then runs _linuxRiDs.Any(x => split[0].StartsWith(x)). "ubuntu.24.04" does not start with any of those prefixes ("ubuntu" is missing), so the function returns null.
In GetAllRuntimeIds, that means:
currentRid = "ubuntu.24.04-x64"is added.AddFallbackswalksctx.RuntimeGraphfor an entry whoseRuntime == "ubuntu.24.04-x64". On modern .NET (8+), framework-dependent deps.json files have an empty or minimalruntimessection (RID graphs were largely retired in favor of portable RIDs), so this lookup misses.GuessFallbackRidis called as the last-resort path → returns null →linux-x64is never added.
So TryLocateNativeAssetInRuntimesFolder only ever tests runtimes/ubuntu.24.04-x64/native/<libname> (which doesn't exist — NuGet places the assets under the portable RID linux-x64) and TryLocateNativeAssetFromDeps never matches a runtime asset either.
strace evidence
strace -f -e openat of the failing run, filtered to glfw probes, showing zero runtimes/linux-x64/native/ lookups:
openat("/lib/x86_64-linux-gnu/libglfw.so.3.3", ...) = ENOENT
openat("/usr/lib/x86_64-linux-gnu/libglfw.so.3.3", ...) = ENOENT
openat("/lib/libglfw.so.3.3", ...) = ENOENT
openat("/usr/lib/libglfw.so.3.3", ...) = ENOENT
openat("<exe-dir>/libglfw.so.3.3", ...) = ENOENT
openat("/lib/x86_64-linux-gnu/libglfw.so.3", ...) = ENOENT
openat("/usr/lib/x86_64-linux-gnu/libglfw.so.3", ...) = ENOENT
openat("/lib/libglfw.so.3", ...) = ENOENT
openat("/usr/lib/libglfw.so.3", ...) = ENOENT
openat("<exe-dir>/libglfw.so.3", ...) = ENOENT
openat("/lib/x86_64-linux-gnu/libglfw.so", ...) = ENOENT
openat("/usr/lib/x86_64-linux-gnu/libglfw.so", ...) = ENOENT
openat("/lib/libglfw.so", ...) = ENOENT
openat("/usr/lib/libglfw.so", ...) = ENOENT
openat("<exe-dir>/libglfw.so", ...) = ENOENT
The bundled lib is on disk and works:
$ ls <exe-dir>/runtimes/linux-x64/native/libglfw.so.3
<exe-dir>/runtimes/linux-x64/native/libglfw.so.3
$ # dlopen + glfwInit on it returns 1, GLFW 3.4.0 with Wayland + X11 + EGL
Repro
Any project that:
- References
Silk.NET2.22.0 - Calls
Silk.NET.Windowing.Window.Create(WindowOptions.Default)on Ubuntu / Ubuntu-derived - Is run from a normal
bin/<config>/<tfm>/build output (nodotnet publish, no<RuntimeIdentifier>)
Workarounds (confirmed)
Any of these makes it succeed:
LD_LIBRARY_PATH="$PWD/runtimes/linux-x64/native" ./MyApp- Symlinking/copying
runtimes/linux-x64/native/libglfw.so.3next to the exe apt install libglfw3(so it's found in/usr/lib/x86_64-linux-gnu/)- Setting
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>in the csproj
Suggested fix
Minimal, low-risk: add "ubuntu" (and probably "pop", "linuxmint") to _linuxRiDs in DefaultPathResolver.cs. That alone unblocks the most common case.
Better fix: when the SDK reports a distro-specific RID like ubuntu.24.04-x64, walk it down to the portable RID linux-x64 directly rather than relying on a hand-maintained distro-prefix list. Modern .NET has been moving toward portable-RID-only for years, so SDK output drifting away from the legacy graph is going to keep happening.
Cross-reference
- #652 — original report, same symptom on Linux
- #661 — landed the resolver chain that should handle this, but the fallback list it depends on hasn't been kept up to date with what
Microsoft.DotNet.PlatformAbstractionsactually returns on newer SDKs
- Ngôn ngữ chính
- C#
- Star
- 5.2k
- Fork
- 477
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/Silk.NET
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
bug good first issue verify-3.0
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Silk.net window failsĐang mởbug verify-3.0
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Invoke function is brokenĐang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Tất cả issue của dotnet/Silk.NET
Issue tương tự
-
[C#]:主页联网更新的提示投稿横幅指向错误Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PCL-Community/PCL-CE#3652 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:frontend bug FE P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
klasolsson81/jobbliggaren#2010 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[aw] Upgrade availableĐang mởagentic-workflows untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: homeblaze type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
RicoSuter/Namotion.Interceptor#630 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Akka.Hosting enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100