Closed
Description
Problem
If Cargo.lock
pins version 1.x.y of a dependency, and --locked
or --frozen
is passed, but 1.x.y is not available in the underlying registry, the error Cargo produces is fairly confusing. For example:
error: failed to select a version for the requirement `autocfg = "^1"`
candidate versions found which didn't match: 1.1.0
Nothing in the error mentions the lockfile or the use of --locked
or --frozen
.
Steps
$ cargo new --bin issue
$ cd issue
$ echo 'autocfg = "<1.1.0"' >> Cargo.toml
$ cargo generate-lockfile
$ cp Cargo.lock Cargo.lock.orig
$ sed -i.bkp 's/<1.1.0/1/' Cargo.toml
$ mkdir -p .cargo
$ cargo vendor > .cargo/config
$ cp Cargo.lock.orig Cargo.lock
$ cargo check --frozen # also happens with --locked
error: failed to select a version for the requirement `autocfg = "^1"`
candidate versions found which didn't match: 1.1.0
location searched: directory source `/local/home/jongje/issue/vendor` (which is replacing registry `crates-io`)
required by package `issue v0.1.0 (/local/home/jongje/issue)`
perhaps a crate was updated and forgotten to be re-vendored?
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.58.0 (f01b232bc 2022-01-19)
release: 1.58.0
commit-hash: f01b232bc7f4d94f0c4603930a5a96277715eb8c
commit-date: 2022-01-19
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Amazon Linux AMI 2.0.0 [64-bit]