-
Notifications
You must be signed in to change notification settings - Fork 712
Use larger conflict set when solver chooses wrong version for package in link group #3327
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
Conversation
… in link group This commit replaces a call to 'lgBlame' with a call to 'lgConflictSet'. 'lgConflictSet' adds the members of the link group to the conflict set. The other members are required, for example, when a linked package's version doesn't match a constraint, and the solver must try other versions for the linked-to package.
Not been paying close enough attention to the solver. Do we have an explanation of what conflict sets are somewhere? |
/cc @kosmikus |
@grayjay Ugh :/ Maybe you are right. What if the version choice for a particular package outside of the link group forces a choice of a package inside the link group? Wouldn't we also have to reconsider that outside package then as well? I should talk to @kosmikus about this. I misunderstood the exact nature of the goal reason chains in the past, and I'm still not 100% sure I understand them now. Perhaps it might be the case that when the link validation walks over the tree, the goal reason chain is all we need to construct the conflict set? |
@ezyang it seems not. I wrote previously in a blog post:
I guess we should add this to the code. |
@grayjay I've pushed another commit to https://github.com/edsko/cabal/tree/pr/FixLinkDeps , which actually deletes |
@edsko I cherry-picked the latest commit, and the test still fails because When testing my branch, I couldn't find a test case that fails because the other link group members' |
Without looking very much at the code, it seems to me that the situation here is this:
The choice My first attempt at a fix would be to record linking choices explicitly, which would mean changing
to
where we use I don't yet fully understand how |
@kosmikus I think we were talking about different failures in the log. I just added line numbering. This pull request adds the linked-to variable to the conflict set on line 26, and your change would fix line 23. I think the failure on line 25 should also add 0.D to the conflict set. |
Thank you. But really all of the conflict sets mentioned in the trace should contain |
@kosmikus I thought about the issue some more, and I think that line 23 doesn't need 0.D because of the way that the tree is structured. Line 23 fails because 1.D-2's version doesn't match the test's constraint. But if the solver backjumps to 1.D, it can try any other version, including 1.D-1, which does fit the constraint. If 1.D-1 then fails with "dependencies not linked", as in this example, that failure should add 0.D to the conflict set. I reran the test and made it print conflict sets for the rest of the failures:
|
@grayjay are these tests on the |
Yes |
@grayjay I also have thought about all this more, and I think I agree with you. I originally thought we could not split the linking from the version choice, but I now believe we can (which is good, because it is what we're doing already by separating version constraints and link groups). So if a conflict arises like here in line 23 only because of the version choice of a linked package, we don't need to include the conflict set of the link group. |
FWIW, this also means I no longer believe we need to change |
This commit replaces a call to
lgBlame
with a call tolgConflictSet
.lgConflictSet
adds the members of the link group to the conflict set. The other members are required, for example, when a linked package's version doesn't match a constraint, and the solver must try other versions for the linked-to package.I merged #3221, #3234, #3237, and @edsko's branch off of #3268 into master to try to find any remaining failures in the solver quickcheck test. The log below is from that branch. This commit adds
0.D
to the conflict set when the solver rejects1.D-1
.I'm still not sure if the conflict set is large enough. Should it also contain the variables from the
GoalReasonChain
s for0.D
and1.D
?