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
Description
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