-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-dependency-resolutionArea: dependency resolution and the resolverArea: dependency resolution and the resolverC-bugCategory: bugCategory: bugCommand-updateS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
Description
Problem
So I have a strange interaction between two tools. I am using cargo upgrade --incompatible
from cargo-edit
to update all packages even if the updates are semver incompatible. After that everything still works fine. Cargo builds without complaining, everything seems fine. But if I run cargo update
after that cargo will downgrade some of the packages.
There might be a good reason for this, I mean cargo-edit
is not an official tool and might do things in a wrong way. But it also is absolutely unclear why cargo downgrades some dependencies, especially since it is building without an issue before the downgrade.
Steps
- clone https://github.com/kamulos/cargoissue
- run
cargo upgrade --incompatible
(version 0.13.0) => a few packages will be updated and theCargo.toml
will be changed - run
cargo update
the following output will appear
Updating crates.io index
Locking 4 packages to latest compatible versions
Downgrading litemap v0.7.4 -> v0.7.3 (available: v0.7.4)
Updating ureq v2.10.1 -> v2.11.0
Downgrading yoke v0.7.5 -> v0.7.4 (available: v0.7.5)
Downgrading zerofrom v0.1.5 -> v0.1.4 (available: v0.1.5)
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.85.0-nightly (4c39aaff6 2024-11-25)
release: 1.85.0-nightly
commit-hash: 4c39aaff66862cc0da52fe529aa1990bb8bb9a22
commit-date: 2024-11-25
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Arch Linux [64-bit]
yuezk
Metadata
Metadata
Assignees
Labels
A-dependency-resolutionArea: dependency resolution and the resolverArea: dependency resolution and the resolverC-bugCategory: bugCategory: bugCommand-updateS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]`cargo update` downgrading crates, it is not clear why[/-][+]`cargo update --incompati` downgrading crates, it is not clear why[/+][-]`cargo update --incompati` downgrading crates, it is not clear why[/-][+]`cargo update -Zunstable-options --incompatible` downgrading crates, it is not clear why[/+][-]`cargo update -Zunstable-options --incompatible` downgrading crates, it is not clear why[/-][+]`cargo update` downgrading crates, it is not clear why[/+]epage commentedon Dec 2, 2024
cargo upgrade
is not needed to reproduce this.With where versions are right now,
cargo upgrade
is just updating version requirements to match the lockfile.Just apply
Before that patch:
With that patch
Its interesting that
ureq
is deciding to upgrade as well as the downgradesLooking at how those get pulled in
Looking at
ureq
These weren't locked down in 2.10.1, see https://github.com/algesten/ureq/blob/2.10.1/Cargo.toml
epage commentedon Dec 2, 2024
My best guess as to what is happening is this is dependent on the order things get resolved
However, I'm not see why changing to compatible version requirements would change the walk order of the dependency tree. @Eh2406 any thoughts?
Besides the lack of consistency in our walk order, I would consider this a bug within ureq. They are trying to enforce MSRV through version reqs which we discourage as it can cause ecosystem-wide pain as has been shown repeatedly. This also prevents their dependents with higher MSRVs from using newer versions. MSRVs should instead be handled through lockfiles. This will be improved in 1.84 as we'll have an MSRV-aware resolver.
kamulos commentedon Dec 2, 2024
Ah the dependency specification of
rustls = "=0.23.19"
sounds really bad 😕 Just recently I wanted to updaterustls
because it had a CVE, butcargo update -p rustls
was doing nothing and telling me nothing why this would not work.So maybe a feature request on the side would be to make issues like that discoverable. Maybe
cargo
could explain this while updating or maybecargo tree
could show which version requirements each crate sets.epage commentedon Dec 2, 2024
Made a note about this at algesten/ureq#878
epage commentedon Dec 2, 2024
#7929 is our issue for explaining why upgrades do not happen.
Eh2406 commentedon Dec 10, 2024
Which lock file cargo generates is not guaranteed. We only guarantee that we try package versions from highest to lowest. We do not guarantee the order we try packages. In situations like this, there are more than one valid lock file that meets that requirement. In practice it is based on a number of implementation details, including how are priority queue deals with duplicates (which could change on any time cargo updates its dependencies), and the order that cargo provides the dependencies to the resolver, and probably many more I haven't thought about. While we do not guarantee any consistency here, we attempt to maintain it, because otherwise debugging the resolver is nearly impossible. All of those implementation details could affect resolution, but do not change from one run of cargo to the next. The relevant heuristic here is that we try requirements with fewer candidates first. We do this because in practice it leads to an exponential speed up in resolution time. Updating a minimum requiremment, even if the version chosen does not change, will reduce the number of candidates that could match. Meaning that it will be decided on earlier, and its dependencies will be provided to the resolver earlier. In this case by loading
libsodium-sys-stable
earlier we end up resolvingureq
earlier. Presumably, before we had one of the three that changed being resolved beforeureq
.yuezk commentedon Jul 16, 2025
I encountered the same problem when running
cargo update
, which downgrades thetauri
-related packages.It can be reproduced with the following steps:
git@github.com:yuezk/GlobalProtect-openconnect.git
5ba7bf2e1830eefa66988dc8dcbe0bff270201a8
commit.cargo update
The
tauri
dependency path is straightforward. I don't understand why it has been downgraded.