Can't run eframe program on wayland.
vol8 opened this issue · 7 comments
Describe the bug
I am on NixOS using Wayland. I am trying to run a simple eframe demo. It builds but when I run the program, I get this error:
Error: WinitEventLoop(Os(OsError { line: 81, file: "/home/vol/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.30.5/src/platform_impl/linux/wayland/event_loop/mod.rs", error: WaylandError(Connection(NoWaylandLib)) }))
To Reproduce
Run this code:
use eframe::{egui, NativeOptions};
fn main() -> eframe::Result {
eframe::run_native(
"My egui App",
NativeOptions::default(),
Box::new(|cc| {
Ok(Box::<MyApp>::default())
}),
)
}
#[derive(Default)]
struct MyApp {
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
});
}
}
There was a guy that had a similar problem but his fix didn't help either.
#4528
Looks like this is a pure winit
problem, so I suggest you report it in that repo instead and maybe link to the issue here
it is not the problem of the EGUI, it is problem of the WSL
issues #3413
it is not the problem of the EGUI, it is problem of the WSL issues #3413
How is that a WSL issue when I am not on Windows? I cannot be using WSL on NixOS.
it is not the problem of the EGUI, it is problem of the WSL issues #3413
How is that a WSL issue when I am not on Windows? I cannot be using WSL on NixOS.
you can enable Ozone Wayland support in Chromium and [Electron] based applications by setting the environment variable NIXOS_OZONE_WL=1. For example, in a configuration.nix
That is why i am saying.... there is problem with the support backup from the OS
it is not the problem of the EGUI, it is problem of the WSL issues #3413
How is that a WSL issue when I am not on Windows? I cannot be using WSL on NixOS.
you can enable Ozone Wayland support in Chromium and [Electron] based applications by setting the environment variable NIXOS_OZONE_WL=1. For example, in a configuration.nix
That is why i am saying.... there is problem with the support backup from the OS
First of all, sry I misunderstood you, I thought you were meaning the windows subsystem for linux lol
I have reported this issue to the winit
repo and they said that I need to have libwayland
installed.
With this I will close the issue because thats just what needs to be installed.
I'll just need a way to somehow link the libwayland
into the Rust binary with something called rpath
?
If anyone figures out how to use that, comment pls
it is not the problem of the EGUI, it is problem of the WSL issues #3413
How is that a WSL issue when I am not on Windows? I cannot be using WSL on NixOS.
you can enable Ozone Wayland support in Chromium and [Electron] based applications by setting the environment variable NIXOS_OZONE_WL=1. For example, in a configuration.nix
That is why i am saying.... there is problem with the support backup from the OSFirst of all, sry I misunderstood you, I thought you were meaning the windows subsystem for linux lol
I have reported this issue to the
winit
repo and they said that I need to havelibwayland
installed. With this I will close the issue because thats just what needs to be installed. I'll just need a way to somehow link thelibwayland
into the Rust binary with something calledrpath
? If anyone figures out how to use that, comment pls
I was able to get an eframe
application to work on my NixOS
machine by linking wayland
, libxkbcommon
and vulkane-loader
to the compiled binary, via something like this on .cargo/config.toml
[build]
rustflags = ["-C", "link-arg=-Wl,-rpath,/nix/store/84839y8j0d4l4d3q048v00h20jdk9lh0-wayland-1.23.1/lib:/nix/store/pxww3rra041yadg758ii500kagr5l090-vulkan-loader-1.3.296.0/lib:/nix/store/i0d0ws5xwix1dvmwp8w1fr4kz61k11x4-libxkbcommon-1.7.0/lib:/nix/store/ymhcg6x5jrw3hx8ik1cji6awiybgp9f7-libglvnd-1.7.0/lib"]
for those "magic" paths, I got them by installing those packages and then nix eval nixpkgs#<package-name>.outPath
(add /lib
at the end), this is the code for the app that I've tested
fn main() {
eframe::run_simple_native("hello", Default::default(), |ctx, _frame| {
eframe::egui::CentralPanel::default().show(ctx, |ui| {
ui.label("hello world");
});
})
.unwrap();
}
Ayyy nice. I will try this out and see if it works for me too!