PistonDevelopers / PistonDevelopers/piston

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'

Open
#1,394 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion
Dominant language
Rust
Stars
4.7k
Forks
235
Avg merge
1m
Merged PRs (30d)
4

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README example's src/main.rs, especially the WindowSettings build at the reported panic location, and compare its dependencies with Cargo.toml and shell.nix. Run the example with cargo run and identify the missing setup; done means the example starts without the NotFound panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.