macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

Runtime panic: X11 backend failed (NixOS)

Open HyperCodec opened this issue 2 years ago • 5 comments

Trying to cargo run the example on NixOS results in the following error:

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/miniquad-0.4.0-alpha.6/src/lib.rs:251:50: X11 backend failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

HyperCodec avatar Sep 05 '23 11:09 HyperCodec

Could you post the backtrace?

And do you use X11/XWayland?

not-fl3 avatar Sep 05 '23 16:09 not-fl3

Could you post the backtrace?

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/miniquad-0.4.0-alpha.6/src/lib.rs:251:50:
X11 backend failed
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:619:5
   1: core::panicking::panic_fmt
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_display
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/panicking.rs:168:5
   3: core::panicking::panic_str
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/panicking.rs:152:5
   4: core::option::expect_failed
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/option.rs:1988:5
   5: core::option::Option<T>::expect
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/option.rs:898:21
   6: miniquad::start
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/miniquad-0.4.0-alpha.6/src/lib.rs:251:17
   7: macroquad::Window::from_config
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/macroquad-0.4.2/src/lib.rs:760:9
   8: macroquad::Window::new
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/macroquad-0.4.2/src/lib.rs:749:9
   9: macroquad_project::main
             at ./src/main.rs:3:1
  10: core::ops::function::FnOnce::call_once
             at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

And do you use X11/XWayland?

I'm not entirely sure (this is a Replit environment), but according to their documentation, they use X11 with VNC but are planning to migrate to Wayland.

HyperCodec avatar Sep 06 '23 11:09 HyperCodec

i can also run it with RUST_BACKTRACE=full if you need more backtrace

HyperCodec avatar Sep 06 '23 11:09 HyperCodec

On NixOS, the X11 library is not located in any "normal" library location (/lib, /usr/lib ...) therefore, miniquad can't find them. I ran in the same issue, and it can be fixed by specifying the correct paths using LD_LIBRARY_PATH.

          LD_LIBRARY_PATH = builtins.concatStringsSep ":" [
            "${pkgs.xorg.libX11}/lib"
            "${pkgs.xorg.libXi}/lib"
            "${pkgs.libGL}/lib"
          ];

put that in your mkShell and it should work.

Gurkinator1 avatar Oct 12 '23 18:10 Gurkinator1

you also need to add ${pkgs.libxkbcommon}/lib (at least on my machine)

xijnim avatar Nov 03 '25 22:11 xijnim