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

Readme example crashes with 'thread 'main' panicked at 'called Result::unwrap() on an Err value: Error { raw_code: None, raw_os_message: None, kind: NotFound }', src/main.rs:8:36' #1394

Open
chrissound opened this issue Oct 28, 2023 · 1 comment

Comments

@chrissound
Copy link

chrissound commented Oct 28, 2023

I'm new to Rust so maybe doing something stupid. I'm using Nixos here, which might be the cause, I've got the following dependencies present (via a shell.nix):

{ pkgs ? import <nixos2305> {} }:
with pkgs; pkgs.mkShell {
  buildInputs = [ 
    xorg.libX11.dev
    xorg.libX11
    SDL2.dev
    SDL2
    pkg-config
    xorg.libXcursor
    xorg.libXcursor.dev
    xorg.libXrandr
    xorg.libXrandr.dev
    xorg.libXi
    xorg.libXi.dev
    rustc
    cargo
  ];
}

src/main.rs:

extern crate piston_window;

use piston_window::*;

fn main() {
    let mut window: PistonWindow =
        WindowSettings::new("Hello Piston!", [640, 480])
        .exit_on_esc(true).build().unwrap();
    while let Some(event) = window.next() {
        window.draw_2d(&event, |context, graphics, _device| {
            clear([1.0; 4], graphics);
            rectangle([1.0, 0.0, 0.0, 1.0], // red
                      [0.0, 0.0, 100.0, 100.0],
                      context.transform,
                      graphics);
        });
    }
}

Cargo.toml:

[package]
name = "elarust2"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
piston_window = "*"

I tried adding the following to Cargo.toml but no difference in output:

piston = "*"
piston2d-graphics = "*"
piston2d-opengl_graphics = "*"
[nix-shell:~/temp/wiptemp/1084/elarust2]$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/elarust2`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { raw_code: None, raw_os_message: None, kind: NotFound }', src/main.rs:8:36
stack backtrace:
   0:     0x55628a0a773a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1792633461806265
   1:     0x55628a0d9c9e - core::fmt::write::h86858dfe747be413
   2:     0x55628a0bbb35 - std::io::Write::write_fmt::h74e0842d6f1ebf1a
   3:     0x55628a0a7505 - std::sys_common::backtrace::print::h18201883e81727b4
   4:     0x55628a0bc4bf - std::panicking::default_hook::{{closure}}::he7684422edfb8e5d
   5:     0x55628a0bc185 - std::panicking::default_hook::h0f55305c4c7e7f71
   6:     0x55628a0bc988 - std::panicking::rust_panic_with_hook::hb89fb9ee5a2c564f
   7:     0x55628a0a8759 - std::panicking::begin_panic_handler::{{closure}}::hc641e1ce95f25c1f
   8:     0x55628a0a7846 - std::sys_common::backtrace::__rust_end_short_backtrace::h6a9bb70d00ab18d8
   9:     0x55628a0bc672 - rust_begin_unwind
  10:     0x5562899f9863 - core::panicking::panic_fmt::h71a20a5609c5aabf
  11:     0x5562899f9cf3 - core::result::unwrap_failed::h44ca259f10509f8c
  12:     0x556289a1053b - core::result::Result<T,E>::unwrap::h597331f170ca1393
                               at /build/rustc-1.69.0-src/library/core/src/result.rs:1090:23
  13:     0x556289a4cdbf - elarust2::main::h6a6936c4b3b0fe14
                               at /home/chris/temp/wiptemp/1084/elarust2/src/main.rs:7:9
  14:     0x556289a4125b - core::ops::function::FnOnce::call_once::hcbc02e36844dc013
                               at /build/rustc-1.69.0-src/library/core/src/ops/function.rs:250:5
  15:     0x556289a0313e - std::sys_common::backtrace::__rust_begin_short_backtrace::h5152bec71642b0be
                               at /build/rustc-1.69.0-src/library/std/src/sys_common/backtrace.rs:134:18
  16:     0x556289a371a1 - std::rt::lang_start::{{closure}}::hef2b4f7e56375f27
                               at /build/rustc-1.69.0-src/library/std/src/rt.rs:166:18
  17:     0x55628a0b19b8 - std::rt::lang_start_internal::h34bd518f25d68bbe
  18:     0x556289a3717a - std::rt::lang_start::ha7ae4e8c99368d61
                               at /build/rustc-1.69.0-src/library/std/src/rt.rs:165:17
  19:     0x556289a4cf2e - main
  20:     0x7f2e268b4b0e - __libc_start_call_main
  21:     0x7f2e268b4bc9 - __libc_start_main@@GLIBC_2.34
  22:     0x5562899f9db5 - _start
  23:                0x0 - <unknown>

cargo tree: https://gist.github.com/chrissound/425d0343bbd69290a9c45a2d0f1c1084

@chrissound
Copy link
Author

Seems to be due to missing libgl according to strace:

recvmsg(3, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
epoll_create1(EPOLL_CLOEXEC)            = 4
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 5
epoll_ctl(4, EPOLL_CTL_ADD, 5, {events=EPOLLIN|EPOLLRDHUP|EPOLLET, data={u32=1, u64=1}}) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 3, {events=EPOLLIN|EPOLLRDHUP|EPOLLET, data={u32=0, u64=0}}) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="\203.\5\0\347\1\0\0\1\0\0\0\1\0\1\0\0\340\3\0\203.\5\0\347\1\0\0\1\0CK"..., iov_len=48}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 48
poll([{fd=3, events=POLLIN}], 1, -1)    = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0010,\09\f\0\0\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 4096
recvfrom(3, "w\0\0\0x\0\0\0y\0\0\0z\0\0\0{\0\0\0|\0\0\0}\0\0\0~\0\0\0"..., 8452, 0, NULL, NULL) = 8452
recvmsg(3, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/bmfc7mrr7kilf45wpfd60davjaqfmagv-gcc-12.2.0-lib/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/jd99cyc0251p0i5y69w8mqjcai8mcq7h-xgcc-12.2.0-libgcc/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/bmfc7mrr7kilf45wpfd60davjaqfmagv-gcc-12.2.0-lib/lib/libGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/jd99cyc0251p0i5y69w8mqjcai8mcq7h-xgcc-12.2.0-libgcc/lib/libGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libEGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/bmfc7mrr7kilf45wpfd60davjaqfmagv-gcc-12.2.0-lib/lib/libEGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libEGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/jd99cyc0251p0i5y69w8mqjcai8mcq7h-xgcc-12.2.0-libgcc/lib/libEGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libEGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/bmfc7mrr7kilf45wpfd60davjaqfmagv-gcc-12.2.0-lib/lib/libEGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/libEGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/jd99cyc0251p0i5y69w8mqjcai8mcq7h-xgcc-12.2.0-libgcc/lib/libEGL.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants