-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command to update Cargo.lock to minimal versions #4100
Comments
Note that we can envision some kind of static solution here, for example, by tagging library functionality with #since attribute. However, actually testing things is still needed, because you may depend on a critical bugfix from the dependency. |
This I think would just involve changing cargo/src/cargo/core/resolver/mod.rs Line 1088 in 3ed3497
|
I am still learning cargo internals, but I would be willing to help someone who wanted to take this on! |
Perhaps there's some way to tackle this problem head-on? Probably not, but it's interesting to think about. Two possible ways I can think of:
|
The relevant line of code has moved to: cargo/src/cargo/core/resolver/mod.rs Line 664 in af60861
I think we would add a arg to: cargo/src/cargo/core/resolver/mod.rs Line 573 in af60861
|
Can give this a try :) |
@Dylan-DPC That is wonderful! The idea is that the sort on line L664 determines the order that cargo tries versions of packages. Currently from newest to oldest and we want to reverse that order.
How can I be helpful!? |
Thanks @Eh2406 will take a look whenever I'm free and see how far I get :) |
If that turns out to be challenging, feel free to ask! |
L364 of which file? |
Sorry I wasn't clear |
From today's meeting.
Problem:
You write a library A, which depends on B, so you put
B = 1.0
in A's Cargo.toml. The you run Cargo build, and Cargo greedily pulls B 1.1 into the lockfile. Then you accidentally start depending on features introduced in 1.1, but you don't changeCargo.toml
. Your test locally pass, and CI passes as well, and you publish a crate whose Cargo.toml is a lie.Solution:
Add
cargo update --minimal
, which generates lockfile picking the minimum possible version of all crates (it's not possible, of course, because there's no total order on dependency graphs, but some heuristics might work well in practice). Then in CI environment you generate the minimal lockfile to make sure you don't accidentally depend on newer than Cargo.toml features.The text was updated successfully, but these errors were encountered: