Unhelpful Cargo error if crate version disappears from registry #10063
Labels
A-dependency-resolution
Area: dependency resolution and the resolver
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
C-bug
Category: bug
S-triage
Status: This issue is waiting on initial triage.
Problem
If the version listed in
Cargo.lock
for a dependency is no longer available from the registry, Cargo fails the build with an error even if--locked
is not passed. The error does not suggest what has happened, or what the user might want to do in response.There are a few reasons why this might happen. For crates.io, the most likely reason is if a crate version must forcibly be removed from a registry, such as due to a DMCA notice, a GDPR "Right to be Forgotten" request, a government injunction, or other factors beyond Cargo and crates.io's control.
For private registries, additional cases may arise, such as if local registries are built on the fly when Cargo is managed by a larger build system, and a version that was published on one developer's laptop (say, while they were offline) never makes it to other developers, but a lockfile mentioning that version is nevertheless checked in.
Steps
cargo new vanish
cd vanish
cargo check
sed -i.bkp 's/1\.0\.1/1.0.100/' Cargo.lock
cargo check
:Possible Solution(s)
This was discussed at some length on Zulip. The challenge here is that if a user runs into this, it's not clear from the error what happened, or what they should do next. The Zulip discussion surfaced two possible solutions:
Cargo.lock
. @Eh2406 suggested this may be a fair amount of work, and @joshtriplett argued that this situation warrants manual user action (cargo update
) to proceed. Cargo continuing to use yanked versions when mentioned in the lockfile also suggests a precedent that Cargo shouldn't move on from the version inCargo.lock
without user intervention.cargo update
(or even specificallycargo update -p <package>
).Option 2 definitely seems like the most promising candidate here, though it does make the second use-case outlined earlier (on-the-fly local registries) more painful as developers may regularly have to run
cargo update
(or the build system would need to do so for them somehow) if they check in their lockfiles. The behavior could arguably be made configurable, but if Option 1 turns out to be complex to implement, that may not be feasible.Notes
No response
Version
The text was updated successfully, but these errors were encountered: