eframe_template icon indicating copy to clipboard operation
eframe_template copied to clipboard

Version 0.30.0 fails to run on Ubuntu 22.04 (Missing x11 feature)

Open c-git opened this issue 1 year ago • 7 comments

Problem description

When I try to run the unmodified template on Ubuntu 22.04. I get the following error.

Error: WinitEventLoop(Os(OsError { line: 764, file: "/home/one/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.30.7/src/platform_impl/linux/mod.rs", error: Misc("neither WAYLAND_DISPLAY nor WAYLAND_SOCKET is set; note: enable the winit/x11 feature to support X11") }))

I haven't tried to resolve it yet. Was looking for the issue for it to see what was the recommend approached and checked the release notes but nothing in either pointed me to a solution. Will update if I find a solution. (Also possible it's only on my machine as I can't seem to find any issues for it.

Explanation of why this issues created on this repo instead of egui main repo

I created the issue here as I can create a PR for a workaround that hopefully others can find until an official fix is implemented (Haven't found the fix yet but wanted a place to document what is happening as I may not finish in one sitting).

c-git avatar Dec 24 '24 03:12 c-git

So I tested adding x11 support by adding the x11 feature flag to efame and that fixed it. I thought I was already on Wayland but when it worked I investigated more and turns out I am indeed on x11. Still glad I created this issue that I will now close in case someone else bumps into this they can also see what solution I used (add x11 feature to eframe).

More info for anyone who is interested based on what I found in this article and reading the error message in light of what I read there. I really wondered why it was that I got a runtime error instead of a compile time error and now I think it is because only at runtime they can tell if you're really using Wayland. If you are WAYLAND_DISPLAY or WAYLAND_SOCKET should be set. Based on what I read those are environment variables and hence only available at runtime. Hence the second part of the error message that says to enable x11 support.

c-git avatar Dec 24 '24 04:12 c-git

This issue is valid, as I ran into it today too.

Perhaps the template should have the x11 feature in there by default? IMO, templates are supposed to work out of the box, and in the current case, it doesn't

DougAnderson444 avatar Jan 18 '25 20:01 DougAnderson444

Ok I see, maybe I'll leave the the issue open until the maintainers can weigh in. There needs to at least be an easy way to surface that you need that feature. I'm not sure which way they will want to go so I'll reopen this for now.

c-git avatar Jan 18 '25 20:01 c-git

Same behavior on Ubuntu 24.04, however adding winit = { version = "0.30.9", features = ["x11"] } to dependencies section in Cargo.toml did not work. Adding the 'x11' feature to eframe crate did:

[dependencies]
egui = "0.30"
eframe = { version = "0.30", default-features = false, features = [
    "accesskit",     # Make egui compatible with screen readers. NOTE: adds a lot of dependencies.
    "default_fonts", # Embed the default egui fonts.
    "glow",          # Use the glow rendering backend. Alternative: "wgpu".
    "persistence",   # Enable restoring app state when restarting the app.
    "wayland",       # To support Linux (and CI)
    "x11",
] }
log = "0.4"

Is this a safe and simple way to fix this issue?

Iwijn avatar Mar 13 '25 08:03 Iwijn

Yeah, that's what I did too. Looks like we need a PR to add this to the template to close this issue

DougAnderson444 avatar Mar 13 '25 13:03 DougAnderson444

Yes that's the fix, I used as well. I don't think it affects newer versions of Ubuntu that use wayland. So I'm on the fence about if we should add it for older machines, would be nice t at least maybe add it commented out or something IDK. The current "approach" isn't great.

c-git avatar Mar 14 '25 01:03 c-git

Created a Pull request https://github.com/emilk/eframe_template/pull/185 to fix this as I suspect it was an oversight. The x11 feature is actually a default.

c-git avatar Mar 18 '25 22:03 c-git