Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting NotSupported(NotSupportedError) when creating an EventLoop under X11 #3603

Closed
StealthyKamereon opened this issue Mar 23, 2024 · 6 comments
Labels
B - bug Dang, that shouldn't have happened DS - x11

Comments

@StealthyKamereon
Copy link

Description

I'm trying to run an application that uses winit. When I launch it it crashes on the following line :

let event_loop = EventLoop::new().unwrap();

I then made a dummy Rust package with only this line and sure enough I have the same crash.

OS and window mananger

I am on Nixos and using Plasma 5.

Winit version

0.29.15

@StealthyKamereon StealthyKamereon added B - bug Dang, that shouldn't have happened DS - x11 labels Mar 23, 2024
@notgull
Copy link
Member

notgull commented Mar 23, 2024

NixOS

Please ensure that all of the following libraries are installed:

  • libx11-dev
  • libxcursor-dev
  • libxcb1-dev
  • libxi-dev
  • libxkbcommon-dev
  • libxkbcommon-x11-dev

@StealthyKamereon
Copy link
Author

It is indeed the problem.
Being on Nixos, dynamically loaded libraries are a bit of a hassle.

I'm closing this ticket as it's not really a bug of winit but rather its underlying lib: x11-rs
I'll write the solution here later when / if I find it for future people that come across this problem.

Thanks

@StealthyKamereon
Copy link
Author

The correct way to do this in Nixos to my understanding is to use nix-ld.

Adding this snippet should enable nix-ld to provide path to the required libs :

programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
    xorg.libX11
    xorg.libXcursor
    xorg.libxcb
    xorg.libXi
    libxkbcommon
];

Unfortunately, it still doesn't work for some reason (see nix-community/nix-ld-rs#26).
The current workaround I found is to set the content of LD_LIBRARY_PATH manually before running the binary:

export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH

I am still looking for a better solution.

@nuxeh
Copy link

nuxeh commented Mar 29, 2024

For what it's worth, I got a similar app with the same error to work using a modification of the nix shell here https://discourse.nixos.org/t/could-not-find-system-library-x11-required-by-the-x11-crate/33751

@freddycansic
Copy link

freddycansic commented Apr 1, 2024

My solution was to include a build.rs in the root directory of the cargo project.

fn main() {
    println!(
        "cargo:rustc-link-search={}",
        std::env::var("NIX_LD_LIBRARY_PATH").unwrap_or_default()
    );
}

This adds NIX_LD_LIBRARY_PATH to the rustc linker library search paths.

Still, it would be nice to use a Nix specific solution.

Reference: https://doc.rust-lang.org/cargo/reference/build-scripts.html

@kchibisov
Copy link
Member

just export LD_LIBRARY_PATH from the nix expression, it has an option to populate this variable. Or you fhs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - x11
Development

No branches or pull requests

5 participants