Rust Amethyst Pong Tutorial Examples give "error: no example target named `pong_tutorial_01`"

813 views Asked by At

I just cloned the github repository amethyst/amethyst, which is a game engine written in rust, in order to follow the docs and tutorials. The document at Amethyst documentation about the pong tutorial tells us that you can run examples using...

cargo run --example pong_tutorial_01 --features "vulkan"

... but when I try this, I get an error...

error: no example target named `pong_tutorial_01`

Now, this business of running code examples that are provided inside a larger project is new to me, but seems to be a proper part of Rust, and the behaviour is defined in the Cargo.toml(s) of the outer project and (I think) the example sub-projects within. But having read through some of the rust Cargo book here, about examples needing to live in the examples subdirectory, and there being ways to prevent their being discovered automatically (e.g. autoexamples = false) unless they are specifically configured another way, everything appears to be in order.

Does any smart person know why this doesn't work, without me learning every single detail of how to configure cargo? Thanks in advance.

ps I'm running on Win 10. Rustup update is up to date. Other rust things work. Indeed, these examples work, if I delve all the way into their directories and run them with cargo run directly, so I don't think I have a language/toolchain configuration problem. I'm just interested as to why that particular command line doesn't work as advertised.

2

There are 2 answers

0
LuckyStreak On

For anyone else stumbling on this post, the above answer is correct for the main branch of the amethyst project.

However, the project currently has two important branches:

  1. The v0.15.3 or stable branch, which is the most recent release on crates.io
  2. The main or master branch, which is under heavy work to eventually release the next version of amethyst

It's important to note that the link given by op is to the stable book, which references v0.15.3. The examples can be run for that version by checking out the correct branch and running the command as the book says:

git checkout v0.15.3
cargo run --example pong_tutorial_01 --features "vulkan"

I would recommend following v0.15.3 for now, since it it well-documented. The main branch has yet to update most of the docs.

0
kmdreko On

It looks like the examples were recently converted from from cargo examples to workspace members. They were largely disabled in this PR and then fixed up as standalone packages in this PR. The latter of which cites dependency management as the reason for the change. The documentation probably hasn't been updated accordingly.

You should be able to use -p/--package instead:

cargo run -p pong_tutorial_01 --features "vulkan"