Cannot load image in ggez/rust due to path not absolute

438 Views Asked by At

I get this strange error that ggez cannot find and load my image file. But even an absolute path still makes an error. Wtf man?

MyGame {
    carimage: Image::new(&mut ctx, "/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/car_yellow_small_5.png").unwrap(),
}

Runtime error:

thread 'main' panicked at 'called Result::unwrap() on an Err value: ResourceNotFound("/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/car_yellow_small_5.png", [("/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/target/release/resources", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })), ("/home/arkadiusz/.local/share/competition8:gamedev", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })), ("/home/arkadiusz/.config/competition8:gamedev", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" }))])', src/main.rs:26:93

The file is there:

$ ll /home/arkadiusz/Dokumenty/competition-0008-gamedev/source/
-rw-rw-r-- 1 arkadiusz arkadiusz   993 lip  7  2015 car_yellow_small_5.png
1

There are 1 best solutions below

3
On

Somehow it solved itself. I dont know how I did it. Sorry.

MyGame {
    carimage: Image::new(&mut ctx, "/car_yellow_small_5.png").unwrap(),
}