rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.68k stars 2.41k forks source link

Mismatch against yanked version doesn't inform user about yank #4260

Open crumblingstatue opened 7 years ago

crumblingstatue commented 7 years ago

Depending on bincode = "1.0.0-alpha7" produces the following error:

no matching version `^1.0.0-alpha7` found for package `bincode` (required by `whatever`)
location searched: registry https://github.com/rust-lang/crates.io-index
versions found: 0.8.0, 0.7.0, 0.6.1, ...

It doesn't mention the fact that there is a 1.0.0-alpha7, but it has been yanked.

This can leave the user confused about whether they mistyped something, or they are just trying to depend on a yanked version.

Semi-related: https://github.com/onur/docs.rs/issues/112#issuecomment-313868337

epage commented 1 year ago

Looks like the error hasn't improved in the intervening time

#!/usr/bin/env nargo
```cargo
[dependencies]
bincode = "=1.0.0-alpha7"

fn main () {}

```console
$ ./cargo-4260.rs
warning: `package.edition` is unspecified, defaulting to `2021`
    Updating crates.io index
error: failed to select a version for the requirement `bincode = "=1.0.0-alpha7"`
candidate versions found which didn't match: 2.0.0-rc.3, 2.0.0-rc.2, 2.0.0-rc.1, ...
location searched: crates.io index
required by package `cargo-4260 v0.0.0 (/home/epage/src/personal/dump)`
if you are looking for the prerelease package it needs to be specified explicitly
    bincode = { version = "2.0.0-rc.3" }
perhaps a crate was updated and forgotten to be re-vendored?

@Eh2406 how bad would this be to improve the error in this case?

Eh2406 commented 1 year ago

The resolver is reporting that the package doesn't exist, because it got filtered out and a much lower level of abstraction. This is part of the work in https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/better.20error.20messages.20for.20filtered.20versions.2E

glandium commented 8 months ago

Not sure I should open a separate issue, but relatedly, the error from cargo update -p crate --precise yanked-version says error: no matching package named "crate" found, which is confusing.

epage commented 8 months ago

Allowing --precise with yanked packages was implemented in #13333. It is currently unstable but we expect to stabilize it soon.