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

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.

Related

Rust-Analyzer failed to load workspace, failing because of dependencies

[ERROR rust_analyzer::reload] failed to switch workspaces:
rust-analyzer failed to load workspace:
Failed to read Cargo metadata from Cargo.toml file
/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me/Cargo.toml,
cargo 1.57.0-nightly (7fbbf4e8f 2021-10-19): Failed to run `cargo metadata --manifest-path
/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me/Cargo.toml`: `cargo metadata` exited with an error: Updating crates.io index error: failed to select a version for the requirement `phf = "^0.11"`
candidate versions found which didn't match: 0.10.1, 0.10.0, 0.9.0, ... location searched: crates.io index required by package `tokio-postgres v0.7.7` ... which satisfies dependency `tokio-postgres = "^0.7.7"` (locked to 0.7.7) of package `postgres v0.19.4` ... which satisfies dependency `postgres = "^0.19.4"` (locked to 0.19.4) of package `remind-me v0.1.0 (/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me)
So this problem is just arising in one rust project of mine. Cargo is in the path and this problem arose when I added one new dependency to my project and now I am stuck with this.
I have tried looking for the answer on the internet and did not find success yet, I do not know what else to try next.
cargo metadata --manifest-path <path to the file>
Works in the console I do not know why is this not working right now.
I am running this on Manjaro and my text editor is Vim with YouCompleteMe being used for AutoComplete.
If someone can point out what is wrong with the dependencies, I would be very thankful.
Thanks.
phf 0.11 requires Rust 1.60. You need to either update your Rust compiler to at least that version, or follow the chain of dependencies and downgrade the postgres crate so that you don't require phf 0.11.

Cargo fails to select a version for rustc_version

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.

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.

Cannot use cargo uninstall to uninstall packages in ~/.cargo: package id specification matched no package

I'm having trouble uninstalling Cargo-installed packages from my system.
There are packages like rand-0.3.22 that are obviously installed under $HOME/.cargo
ls ~/.cargo/registry/src/github.com-1ecc6299db9ec823/ra
racer-2.0.14/ rand-0.3.22/ rand-0.4.2/
rand-0.4.3/ rand-0.5.5/ rand_core-0.2.1/
rawpointer-0.1.0/ rayon-1.0.2/ rayon-core-1.4.1/
This can also be verified by using cargo pkgid
cargo pkgid -p rand
error: There are multiple `rand` packages in your project, and the specification `rand` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
rand:0.5.5
rand:0.4.3
rand:0.3.22
However, I'm unable to remove that package with cargo uninstall. None of these seem to work:
cargo uninstall rand
cargo uninstall -- rand:0.4.3
cargo uninstall https://github.com/rust-lang/crates.io-index#rand:0.4.3
For any of the commands above I get:
error: invalid package id specification: <name-of-package-i-specified>
This seems like a rather basic operation so I suspect it's something fundamental to how cargo-uninstall is to be used.
Any pointers?
cargo uninstall undoes the effect of cargo install. You did not cargo install rand, because it is just a library, not an executable program. That means it was not installed.
The ~/.cargo/registry is just a cache of build dependencies. Feel free to wipe it anytime; cargo will re-download and re-build whatever it needs when it does.
Yes, it is wrong. Cargo should be using .local, .config and .cache as appropriate; then it would be obvious what you can just clean up. Using arbitrary dot-dirs is an insult at this day and age. It was reported, several times probably. Nobody got around to fixing it yet.

Resources