Open
Description
Problem
When [patch]
ing a crate foo
of version x.y.z
(where x.y.z
is not the most up-to-date version), running cargo update -p foo --precise x.y.z
twice causes foo
to be updated to the latest version (rather than x.y.z
).
Steps
- Clone
libc
to/tmp
and downgrade to an old version (let's take0.2.93
) using:git checkout tags/0.2.93
cargo new foo
- Modify
foo/Cargo.toml
:
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dependencies]
libc = "0.2"
[patch.crates-io]
libc = { path = "/tmp/libc" } # Path to our 0.2.93 version of libc
- Run:
$ cargo update -p libc --precise 0.2.93
Updating crates.io index
warning: Patch `libc v0.2.93 (/tmp/libc)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
Adding libc v0.2.93 (/tmp/libc)
Removing libc v0.2.94
- Run again:
$ cargo update -p libc --precise 0.2.93
Updating crates.io index
warning: Patch `libc v0.2.93 (/tmp/libc)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
Removing libc v0.2.93 (/tmp/libc)
Adding libc v0.2.94
Note that the last two lines of output are different in steps 4 and 5.
Notes
Output of cargo version
:
cargo 1.53.0-nightly (65d57e6f3 2021-04-04)
It appears that without [patch]
everything behaves as expected - running the same update
more than once has no effect.
This may seem like an odd set of circumstances. I would be happy to explain why we run into this situation if it helps.