I'm learning Rust from "Practical Rust Projects" by Shing Lyu. I'm now trying to build a game following the steps in Chapter 4. I'm working on Ubuntu 18.04 LTS.
After installing Rust and the Amethyst command line, I created a new project via amethyst new cat_volleyball
. The next step is to run the engine using cargo run --features=vulkan
. When I do so, I get the error prompt below. Do you have suggestions on how to fix this?
error[E0433]: failed to resolve: could not find `__rt` in `quote`
--> /home/alberto/.cargo/registry/src/github.com-1ecc6299db9ec823/err-derive-0.1.6/src/lib.rs:145:63
|
145 | fn display_body(s: &synstructure::Structure) -> Option<quote::__rt::TokenStream> {
| ^^^^ could not find `__rt` in `quote`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: could not compile `err-derive`.
warning: build failed, waiting for other jobs to finish...
TL;DR Edit the Cargo.lock
manually, please check the title below for the proper steps : How to force cargo to use yanked version of sub-dependency
Because err-derive-0.1.6
is using quote-1.0.2
as a dependency and quote is declared like below:
[dependencies.quote]
version = "1.0.2"
It means Cargo will use the latest patch update, so if quote-1.0.3
is out then cargo will use 1.0.3
instead 1.0.2
. Please check caret-requirement. The problem in here is quote-1.0.3
breaks the backward compatibility, the part that used by err-derive-0.1.6
is no longer exists in quote-1.0.3
.
You can fix this issue by forcing the sub-dependency to use compatible version for your dependency. This command will do it :
> cargo update -p quote --precise 1.0.2
Looks like quote-1.0.2
was yanked from crates.io, so command up above will not work because cargo will not be able to find the yanked version on crates.io . Since cargo update modifies the cargo.lock
we can do it manually. To start clean :
Cargo.lock
cargo update
( this will generate the latest version of Cargo.lock
)Cargo.lock
:Find the incompatible version of package in cargo.lock which is quote-1.0.3
, It should look like this:
[[package]]
name = "quote"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
then simply change version to the compatible version in our case it is "1.0.2"
[[package]]
name = "quote"
version = "1.0.2"
After doing that do not run cargo update again, it will overwrite your changes and you'll not able to compile your project. Please remember this is a workaround for being able to continue the development, there is a reason to yank crates, do not use it in production it is best to wait dependent crates to update itself.
Note : In some cases you may get an error after editing cargo.lock
:
error: Found argument 'Cargo.lock' which wasn't expected, or isn't valid in this context
@albus_c fixed this by doing :
A note for posterity: I fixed the issue removing rustc (
sudo apt remove rustc
) and reinstalled as recommended on the Rust website,curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After that everything worked fine.