-
Notifications
You must be signed in to change notification settings - Fork 711
Consistently use the Cabal version picked by the dependency solver. #3723
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
Previously, cabal always chose a Cabal library version to use for a package's setup script that didn't take setup-depends into account (cabalLibVersion). cabalLibVersion depended on the cabal-version field, the installed versions of Cabal, etc., and it was used when setup dependencies were not chosen by the dependency solver. When a package had a setup-depends, cabalLibVersion was later ignored in favor of the version chosen by the dependency solver. However, calculating the variable caused an error when the only suitable Cabal version was installed during the same install command (issue haskell#3436). cabalLibVersion was also used to filter the configure flags (issue haskell#3433). This commit sets cabalLibVersion to the version chosen by the dependency solver, when possible.
,SetupScriptOptions) | ||
cabalLibVersionToUse = | ||
case useCabalSpecVersion options of | ||
Just version -> do | ||
case find (hasCabal . snd) (useDependencies options) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd appreciate a comment laying out the logic here, and a reference to the issues that arise when you don't do it correctly. (Yes you can blame, but right now it's not even obvious something nontrivial is going on here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the solver pass the Cabal version to us as useCabalVersion
? Can we just use that instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@23Skidoo The comment over the useCabalVersion
field says that it should be used when useDependenciesExclusive
is not set, so it isn't always set by the dependency solver. I used useDependencies
because SetupWrapper already uses it to check whether the solver has picked a Cabal version:
if any hasCabal (useDependencies options') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grayjay I think the comment refers to the fact that if useDependenciesExclusive
is set, then we should just use those dependencies exclusively, including the dependency on Cabal. If you look at the code, in both places we set useDependencies
, we also set useCabalVersion
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just a bit worried that the already complicated logic in this file is becoming more complicated, so I'm thinking about how we can make it simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code still needs to determine whether the solver chose the Cabal version, though, which would be hard to determine from useCabalVersion
. If the solver chose a Cabal version then we could use useCabalVersion
. But I didn't want to change the behavior in the case that the solver didn't choose any setup dependencies or chose setup dependencies that didn't include Cabal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's merge your patch as-is and refactor the logic some other time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezyang I pushed a new commit with comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@23Skidoo I agree that the logic is becoming complicated. We could separate out the old and new code paths, as suggested here #3094 (comment). Then it would be easier to see which SetupScriptOptions
apply in each case.
LGTM. |
/cc @edsko I think this should also go into the 1.24 branch. |
Thanks @grayjay, the docs are much appreciated. Reading them, I wonder: how does the solver decide which version of Cabal to pick? Clearly it tries to respect setup dependencies, but do any of the other parameters feed into it? Based on what I've seen, I don't think so, but I could be wrong? |
@ezyang AFAIK, the solver only considers the setup dependencies. It ignores |
Yeah, it seems to me applying |
OK, so I was trying to document |
@ezyang Do you mean |
Nope, I'm referring to the |
IIRC, |
OK, but that doesn't answer all my questions:
Does anyone actually use this? Maybe we should drop it. |
I opened an issue, #3751. Should I merge this and create a PR for 1.24? |
I think it does, in that case it forces the external setup method.
It predates the introduction of
I don't think so. Normally you use it in a single package directory anyway.
I haven't used it much lately. I think that one can now use a package with a setup dependency on Cabal for the same purposes. |
Previously, cabal always chose a Cabal library version to use for a package's
setup script that didn't take setup-depends into account (cabalLibVersion).
cabalLibVersion depended on the cabal-version field, the installed versions of
Cabal, etc., and it was used when setup dependencies were not chosen by the
dependency solver. When a package had a setup-depends, cabalLibVersion was later
ignored in favor of the version chosen by the dependency solver. However,
calculating the variable caused an error when the only suitable Cabal version
was installed during the same install command (issue #3436). cabalLibVersion was
also used to filter the configure flags (issue #3433).
This commit sets cabalLibVersion to the version chosen by the dependency solver,
when possible.
I added an integration test for issue #3436 in the second commit. I also added two more custom-setup tests in the third commit, but they passed before this change.
EDIT: This fixes #3433, #3436, and #3475.