-
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
Cargo fails to find minimal satisfiable set of dependencies #4902
Comments
@SergioBenitez are we working on the same issue (pooling) ? lol |
Thanks for the report @SergioBenitez! Right now I think this is two bugs in Cargo playing into effect:
|
@alexcrichton Have you considered removing all heuristics from Cargo in exchange for using an optimizing SMT solver to get an optimal set of dependencies? I read in some other issue that z3 was proposed long ago, but I didn't see that discussion develop further. I would be open to leading the implementation of such an overhaul, though I won't have the necessary bandwidth for some time. |
@SergioBenitez yes it's been discussed from time to time but never too seriously. I'm mostly of the opinion that it appears like a panacea and yet is likely to take quite a bit of effort to reach feature/speed parity with the current algortihm. Additionally I don't think it'd actually affect this issue. The problem here is that a constraint isn't encoded into resolution, not that we can't encode it into resolution. A real sat solver AFAIK would only bring a possible benefit of speed in degenerate cases Cargo hits today. |
@alexcrichton Using an optimizing SMT solver would solve this issue as the optimal set of dependencies is the correct one. There wouldn't be a special case here, nor a need to encode a specific constraint. I've run into quite a few cases over the years where Cargo makes an incorrect or suboptimal choice; using an SMT solver would bring my fears that Cargo is liable to do that to rest. It's possible that using something like z3 would slow things down, but z3 has been heavily tuned over the years, so it's at least worth a shot, in my opinion. |
Actually moving to someting like a real solver is a pretty huge investment, so I'm not really the one to make such a decision. It would be @rust-lang/cargo which would weigh in on such a decision. |
@alexcrichton the biggest issue with using an off-the-shelf solver, in my experience, is getting good error messages when something goes wrong. My second biggest concern is making sure whatever we take a dependency on is reliable and not something we're going to regret down the road. Before committing to using an off-the-shelf solution, I would want to see a prototype that handled strictly more cases than Cargo correctly, and produced actionable error messages. I would also want some confidence that we could continue to refine and improve the error messages over time. |
What is involved in adding this? If we can make the info available during resolution then I think it is just adding the test to resolve RemainingCandidates::next. But I don't know how to make the info available. |
@Eh2406 unfortunately it's not a very trivial change at this point. The index is all Cargo has during crate graph resolution and the index doesn't encode the |
Is it possible to add info to the index in a backwards compatible way? If so we can add that info for crates published into the future. Older I think I understand |
Yeah we'd in general just have to assume that anything missing such a key in the index doesn't have it, and it'd act as if it does today. If we feel the need we could retroactively fill the registry but we probably wouldn't do that to start out. |
If we add a key to the index will old versions of cargo stop working? Specifically will they return an error when the json is not the shape it has always been? |
@Eh2406 nah in general Cargo's relatively lenient about parsing the registry, if there's a key it doesn't undrestand in the blobs it'd just ignore the key. So long as we're additive in what's inserted it shouldn't be a problem! |
cc @joshtriplett re: new key leniency |
Thanks, @wycats. I've had mixed experiences with adding new keys in the Cargo registry and having older versions choke. Please test this explicitly, including with both old and current versions of Cargo. If you add it in the right place, it shouldn't cause issues; if you add it in the wrong place, Cargo will break even if it doesn't care about that crate version. |
Only allow one of each links attribute in resolver This is a start on fixing the `links` part of #4902. It needs code that adds the links attribute to the index. But, I wanted to get feedback.
As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it. I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect? The team would be especially grateful if such a comment included details such as:
Thank you for contributing! (The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.) If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable! |
Thanks stale bot for bringing this to my attention. I will close it now. This issue has 3 parts.
|
I'm currently experiencing an issue where Cargo selects two different versions of a
-sys
crate when one version of the-sys
crate is enough to satisfy dependency constraints. In my particular case, myCargo.toml
[dependencies]
look like:Both crates depend on
libsqlite3-sys
. Here's what they list in their dependency section:Here's what Cargo decides for these constraints:
Or, as seen from
Cargo.lock
:This is a suboptimal choice. What's worse, because this is a
-sys
dependency, this causes compilation to fail needlessly. The optimal, correct decision is to chooselibsqlite3-sys 0.9.1
for both dependencies.The text was updated successfully, but these errors were encountered: