-
Notifications
You must be signed in to change notification settings - Fork 844
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
Solver: Not all unsatisfied constraints are marked as "(user goal)". #3966
Conversation
I haven't worked on the |
We only need to search for the goals that cabal is targetting, not all of the packages that are being tried as well.
I've tested it the current commits with |
It looks like the code in question was originally added in b7c535f by @harendra-kumar. Harendra: would you mind having a look at this? |
Yeah, I remember writing this code, will take a look tomorrow. |
@Mokosha can you help me understand why you had to make the parsing changes? I see there is a "trying:" line in your travis example output so it should have been parsed by the existing code? I am surely missing something here. The idea behind this code is to roughly detect the "user packages" that are causing the conflict so that we can try again after omitting those packages from the config and that's why I had put the "user goal" restriction in parsing. Can you help me understand how and why the modified code works as expected? |
Hey @harendra-kumar, sure. In the example, I don't have a good sense of what circumstances would cause |
@Mokosha thanks for the explanation. This code is meant for detecting user packages i.e. the packages that you are building or have in your repository or in other words the packages that are not dependencies. When the solver is unable to come up with a good plan, as a last resort, it tries to find which user packages are causing a conflict and then remove those packages from the plan and try again including only the remaining packages in the build plan. When you have only one package in your repo this algo does not make much sense as it will ignore the only package you are building. It is useful when you have many packages and you could do without some of them. With that in mind, do you think this change is helpful? Can you point to a stack.yaml produced by this? Is the stack.yaml that it produced working correctly to build the package? |
If the intended goal is to remove local packages from consideration from cabal, then I suppose this change does not help achieve it. However, the previous version of the code didn't seem to do that either. This code is only being used in the top-level In particular, the set of packages sent to cabal as constraints involve all packages (user or otherwise) and their dependencies that are required but not in the current resolver. If this is not the intended use-case, then you have a different bug in the To answer your questions:
With the current version of
With the current changes,
This proceeds to build fine. Every |
@Mokosha @harendra-kumar I'm just reviewing open PRs and wanted to check in: any thoughts on next steps here? |
@snoyberg, sorry I missed the previous update by @Mokosha .
The intended logic that I implemented long ago was to detect the user packages involved in a conflict and try ignoring one of them as a last resort. It was working perfectly earlier, I have not tested it recently though. But I see the code to achieve that seems to be still there. If you see, What your change is doing effectively is to somehow make |
It's unclear to me how my change breaks that logic -- it seems to be relaxing the constraints on the parsing, not removing them. Correct me if I'm wrong, but it seems like your suggestion is to keep the incorrect parsing and instead ignore the failure it produces? Changing |
The intended logic is to detect the "user packages" involved in the conflict, not any package. Because we want to omit a user package and then try again. With the relaxed constraints, it is no longer guaranteed to be a user package.
We need to understand why the original change proposed in the PR seems to work. As per my (maybe incomplete) understanding of the code, when you parse the cabal output incorrectly it will pass non-user packages to be ignored, which should be as good as returning an empty list unless something funny is going on. Now, I could not spent enough time trying to understand what's going on, can you please dig a little bit and explain why exactly your change is working? |
Hi -- Sorry for the delay. I guess I'm confused about the distinction between "user packages" and just any package that's sent as a constraint to cabal. 95% of the time, the "next goal" according to the output will be a user package as that's the constraint that cabal is trying to solve. In certain scenarios, like the one provided in the examples, the constraint is not a "user package". The packages that we choose to omit from the ones listed as constraint flags to cabal shouldn't be restricted to just "user packages" as there are others (e.g. dependencies) that we might want to omit to let cabal provide a better solution to the overall goal of building the main package.
It isn't, as you can see in the examples. There are situations where certain packages are incompatible, like in the case of Does that help? I might not be explaining this using the right terminology... |
The idea as I designed it was this - when we have more than one user packages under the tree and we cannot find a working build plan when we include all of them, because their dependencies conflict, then as a last ditch effort we try omitting one package from the conflicting ones and see if we can find a plan. If we find a plan then that particular package is removed from the list of packages in the Now, if we want to apply this sort of omitting of packages to dependencies then I am not even sure what it means. I am not even sure what exactly is making it work for you, that's why I asked you to dig further. My guess was that you are just sending a non-user package, which is as good as sending an empty list because we are not going to omit it as it is not a user package. You need to figure out what's going on. |
OK -- I may have a misunderstanding of what the goals of the If this isn't the case, then I may have misunderstood the goal of the If my understanding of the intent of the Rereading the thread, I now understand that the original intent of the code was to support directories that contain multiple user packages. In these cases, if conflicts arise (regardless of whether or not they are marked as |
@Mokosha omitting of packages is an optional feature, disabled by default and enabled by a command line flag. It can omit one or even all packages, in the latter case a The problem here is that we generate a list of conflicting packages irrespective of the status of omit-packages flag. If omit-packages is not enabled we do not need even execute this code, but we do. You can possibly pass a flag down to the solver to enable or disable this behavior based on the omit flag. I am not sure whether your code actually breaks the existing logic, but it will include more cases and may also include non-user packages in the output. I have not looked at how that case is handled in the upper level callers, do we just ignore non-user packages (in which case it would be harmless) or not. So your options are:
|
I unfortunately don't have time to work on this, so I'm closing this PR in favor of the tracking bug #4319 . |
As an example, see:
https://travis-ci.org/Mokosha/Lambency/jobs/366406973
Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.
Please include the following checklist in your PR:
Please also shortly describe how you tested your change:
I locally tested the sequence of normal commands for my personal project that were failing on travis.ci:
The solver seems to only have been tested with this version of cabal. It's probably better to try and update the version of cabal that it depends on, but this at least fixes a bug in the current implementation.