So I followed the Amethyst Pong tutorial and am now building a little Game of Life program. It works fine if I run it with cargo run
but if I do cargo build
and then run
$ .\target\debug\game_of_life.exe
I get the error:
Error: Error { inner: Inner { source: None, backtrace: None, error: ConfigError(File(Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." })) } }
If it was not already clear I am on Windows 10. I also created a blank rust project and tried running the executable of that and it worked fine:
$ cargo new temp
$ cd temp
$ cargo build
$ .\target\debug\temp.exe
Hello, world!
steps to reproduce (must have cargo and vulkan installed):
$ cargo install amethyst_tools
$ amethyst new temp
$ cd temp
$ cargo build
$ .\target\debug\temp.exe
Error: Error { inner: Inner { source: None, backtrace: None, error: ConfigError(File(Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." })) } }
note that this:
$ amethyst new temp
$ cd temp
$ cargo run
works fine
Versions:
$ amethyst --version
Amethyst CLI 0.10.0
$ cargo --version
cargo 1.43.0 (3532cf738 2020-03-17)
Any ideas or any more information I should provide?
Your main function calls application_root_dir which is part of Amethyst.
The definition of application_root_dir shows that it is either using CARGO_MANIFEST_DIR
or the location of your executable as your root path (which is later used to find assets and configuration). When you invoke cargo run
, it sets CARGO_MANIFEST_DIR
to the directory of the currently built crate's Cargo.toml, whereas if you invoke the binary directly CARGO_MANIFEST_DIR
does not get set at all (so it will try to use .\target\debug
as the base-path to find configs/assets).
You can either copy the binary to the location of your Cargo.toml
or set CARGO_MANIFEST_DIR
manually, and then you should be able to execute your binary directly.