Cargo fails to select a version for rustc_version - rust

My project compiles fine on other machines, but on a new one with fresh rustup I get the error
$ cargo build
Updating crates.io index
error: failed to select a version for the requirement `rustc_version = "^0.1"`
candidate versions found which didn't match: 0.3.3, 0.3.2, 0.3.1, ...
location searched: crates.io index
which doesn't make sense to me. Why does 0.3 not match ^0.1?

All versions of the rustc_version crate before 0.2 have been yanked. That and cargo considers changes to the minor before 1.0 to be incompatible.
It may work on other machines if a pre-0.2 version of rustc_version is in their Cargo.lock file or if it had already been downloaded and cached.

Related

What does "package foo in Cargo.lock is yanked in registry" mean?

I was trying to install ripgrep_all using cargo install ripgrep_all. It gave the following error:
% cargo install ripgrep_all
Updating crates.io index
Installing ripgrep_all v0.9.6
error: failed to compile `ripgrep_all v0.9.6`, intermediate artifacts can be found at `/tmp/cargo-install5HlOMt`
Caused by:
failed to select a version for the requirement `cachedir = "^0.1.1"`
candidate versions found which didn't match: 0.3.0, 0.2.0
location searched: crates.io index
required by package `ripgrep_all v0.9.6`
Then I searched a bit and found:
It looks like cachedir yanked version 0.1.1.
And the solution was to:
cargo install --locked ripgrep_all
I was able to install it successfully. However, During the installation it said:
% cargo install --force --locked ripgrep_all
Updating crates.io index
Installing ripgrep_all v0.9.6
warning: package `cachedir v0.1.1` in Cargo.lock is yanked in registry `crates.io`, consider running without --locked
warning: package `smallvec v1.4.0` in Cargo.lock is yanked in registry `crates.io`, consider running without --locked
It made me curious. What does Yank mean in rust world?
It means that the package has been marked as "yanked". This is usually done when the authors of have package have a very compelling reason that a certain version of a package should not be used at all, and to very strongly suggest that the package should not be used. You can ignore yanks with --force to force yanked packages to be used, but that is usually a bad idea: packages were usually yanked for a good reason.
In your case: The yanked cachedir 0.1.X version is a completely different package with a different author than the newer versions. The older versions are unmaintained and cannot be updated (since cachedir now has a different owner who publishes a different package), so the new owner of cachedir yanked the older versions. smallvec 1.4.0 has a bug where it causes Undefined Behaviour when used with zero-sized types, and that UB is bad enough that it is exceedingly unlikely that you actually want to use that version. The fix to this is to update to a later version of smallvec that doesn't have that bug.

Force jlrs to use newer bindgen?

I'm trying to use the jlrs crate (v0.6),
which depends on jl-sys version 0.8,
which depends on bindgen version 0.54.1,
which is yanked.
When I run cargo update it says:
Updating crates.io index
error: failed to select a version for the requirement `bindgen = "^0.54.1"`
candidate versions found which didn't match: 0.55.1, 0.55.0, 0.54.0, ...
location searched: crates.io index
required by package `jl-sys v0.8.0`
... which is depended on by `jlrs v0.6.0`
So far as I can see, jl-sys requires exactly bindgen version 0.54.1, which has been yanked. Is there an easy way to persuade it to use a newer version?
#Herotar was right about the [patch] section being what I needed.
First I checked out https://github.com/Taaitaaiger/jlrs which contains the jl-sys source. Then I bumped the version of bindgen referenced in jl-sys to 0.55
Modified my Cargo.toml like this
[dependencies]
jlrs = "0.6"
jl-sys = "0.8.0"
[patch.crates-io]
jl-sys = { path = '/home/me/jlrs/jl_sys' }
Then it all worked.

Rust & Amethyst - Error [E0433]: failed to resolve: could not find `__rt` in `quote`

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 : How to force cargo to use yanked version of sub-dependency (for the proper steps)
Why this happens ?
This happened because in err-derive-0.1.6 is using quote-1.0.2 as dependency but in it's cargo.toml dependency declared like this:
[dependencies.quote]
version = "1.0.2"
This means cargo will use the latest minor 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 backward compatibility that comes from quote-1.0.2. In this case quote
How to force cargo to use specific version of sub-dependency
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
How to force cargo to use yanked version of sub-dependency
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 :
Remove Cargo.lock
Run cargo update ( this will generate latest version Cargo.lock )
Edit 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.

Unable to build rust's Rocket project because of framework dependency error

I'm following this tutorial here and have also looked into Rocket's official guide of setting up a web server.
I've set as default the nightly builds. But I get the following error:
error: failed to select a version for the requirement `ring = "^0.11.0"`
candidate versions found which didn't match: 0.16.11, 0.16.10, 0.16.9, ...
location searched: crates.io index
required by package `cookie v0.9.1`
... which is depended on by `rocket v0.3.6`
... which is depended on by `my-project`
Obviously there's some mismatch with the dependencies, but since ring is something required by the framework itself, I'm not sure how to debug this... furthermore, I'm using the latest versions of cargo and rust:
cargo 1.43.0-nightly (... 2020-02-18)
rustc 1.43.0-nightly (... 2020-02-21)
ring v0.11.0 was yanked from crates.io (see this issue for some background). Since some versions rocket depended on versions of ring that were yanked, those versions of rocket will no longer work.
Upgrading to rocket v0.4.0 (or the latest v0.4.2) should solve this issue.

Is it possible to download previous nightly builds?

I have downloaded the latest Rust nightly and added this dependency to Cargo.toml:
[dependencies.http]
git = "https://github.com/chris-morgan/rust-http.git"
I'm getting lots of errors for cargo build:
...
error: aborting due to 7 previous errors
...
error: aborting due to previous error
Could not compile `regex`.
I guess this is because some dependencies have not been updated to the latest rust version. Is it possible to download the nightly from yesterday or the day before?
Installed versions:
$ rustc --version
rustc 0.13.0-nightly (c89417130 2015-01-02 21:56:13 +0000)
$ cargo --version
cargo 0.0.1-pre-nightly (1a1868b 2014-12-31 21:39:41 +0000)
If you are using rustup (the currently preferred manner of installing Rust):
rustup install nightly-2016-06-03
If you want to use the standalone Rust installers, previous versions are kept. From this Reddit thread, which links to this Rust issue:
They are officially hosted.
wget https://static.rust-lang.org/dist/2014-12-08/rust-nightly-x86_64-apple-darwin.pkg
wget https://static.rust-lang.org/dist/2014-12-12/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
If you are still using rustup.sh (not .rs), you should be able to use something like:
rustup.sh --channel=nightly --date=2016-06-03

Resources