Skip to content

Combine non-installable & non-upgradable packages #8712

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

Merged
merged 7 commits into from
Feb 28, 2023

Conversation

wismill
Copy link
Collaborator

@wismill wismill commented Jan 30, 2023

Combine non-installable and non-upgradable packages list.

Since the two lists are synced, we try to keep the list in Distribution.Client.Dependency (preferred location) and pass it as a parameter to functions in Distribution.Solver.Modular.Solver.

Fixes #8581


Please include the following checklist in your PR:

Please also shortly describe how you tested your change. Bonus points for added tests!

@wismill wismill requested a review from grayjay January 30, 2023 09:32
@wismill wismill marked this pull request as ready for review January 30, 2023 13:16
Copy link
Collaborator

@grayjay grayjay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for simplifying the non-upgradeable package constraints! This PR is a big improvement and can be merged as is, though I think it could go further to resolve #8581 by also removing the requireInstalled function. The current PR is a straightforward refactoring and doesn't need any additional testing, but removing requireInstalled has the potential to change behavior, so it might help to add more unit tests if you choose to remove that function.

wismill and others added 2 commits February 1, 2023 10:15
Co-authored-by: Artem Pelenitsyn <[email protected]>
@wismill
Copy link
Collaborator Author

wismill commented Feb 1, 2023

@grayjay I gave a try removing requireInstalled. Let us see if it passes the test suite as it is. I should remove the field allowBootLibInstalls in SolverConfig as well.

There are already some tests in cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs. I will need help with use case to design new tests.

@ulysses4ever
Copy link
Collaborator

It may have been wiser to do the second part (requireInstalled business) as a separate PR. That way we could merge this faster.

@wismill
Copy link
Collaborator Author

wismill commented Feb 1, 2023

Yes, I can try a separate PR. I reverted the commit.

As I suspected, it is not as simple as to remove requireInstalled (see failed tests).

@grayjay I think we need to add constraints in a similar way than dontUpgradeNonUpgradeablePackages, don’t we?

@@ -710,7 +717,8 @@ resolveDependencies platform comp pkgConfigDB solver params =
$ fmap (validateSolverResult platform comp indGoals)
$ runSolver solver (SolverConfig reordGoals cntConflicts fineGrained minimize
indGoals noReinstalls
shadowing strFlags allowBootLibs onlyConstrained_ maxBkjumps enableBj
shadowing strFlags allowBootLibs nonUpgradeablePackages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add some comment as to why the nonInstallablePackages field is initialized with nonUpgradeablePackages (there’s a clear mismatch here)? Perhaps, reference a place where the difference between noninstallable and nonupgradeable is discussed? @grayjay, do you happen to know such a place? Or if there’s none, perhaps you could help with writing the comment I’m asking for. This stuff is very confusing and I hope we can write up something that could clear things up for the future reference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ulysses4ever I think that non-installable and non-upgradable may have the exact same meaning, which is the reason I opened #8581. If this PR is merged as is, then I think it can just have a comment pointing to #8581. If it is possible to remove requireInstalled, then this part of the change can be reverted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment

Copy link
Collaborator

@ulysses4ever ulysses4ever Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we agree that "non-installable" and "non-upgradable" are the same, can we please rename one of these into the other?

@wismill thanks for the comment. Can you also update the comment on nonUpgradeablePackages to say that they are the same?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ulysses4ever I'm not completely sure that non-installable and non-upgradable are the same. I wasn't able to determine the difference by looking at the history of the code, so I think that the best way to answer the question is to try to remove one of them and see whether the tests pass. I think it would be better to just link to issue #8581 until we can try removing the rest of the redundant code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current code fullfils @grayjay comment, so I will wait you reach an agreement 😉.
Once this PR is merged, I can try the proposed follow-up.

@grayjay
Copy link
Collaborator

grayjay commented Feb 4, 2023

@wismill Thanks for trying to remove requireInstalled. I think it would be better to merge this PR with only the refactoring change first, since there was a test failure.

It looks like the test failure could have been caused by this line:

| Set.notMember (mkPackageName "base") (depResolverTargets params)

I'm not sure what the purpose of that line was, but I'm guessing that it was made obsolete by the flag --allow-boot-library-installs and can be removed.

There are already some tests in cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs. I will need help with use case to design new tests.

Testing for a larger part of the error message in "Refuse to install base without --allow-boot-library-installs" is probably enough.

@grayjay I think we need to add constraints in a similar way than dontUpgradeNonUpgradeablePackages, don’t we?

I don't think we need to add any more constraints than the ones in dontUpgradeNonUpgradeablePackages. They already prevent that list of packages from being installed.

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Feb 11, 2023

@wismill after grepping the source, I have another proposal that may help to lower my confusion. Could you change the name of the binding you introduced as nonUpgradeable to nonInstallable? My reasoning is that I firmly believe that if we try to stick to one name (non-installable v non-upgradeable) it would be easier to understand the source. And currently, the source seems to use non-upgradeable non-installable more often.

I'd also suggest to change cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs:64 from non-upgradeable to non-installable.

@grayjay
Copy link
Collaborator

grayjay commented Feb 12, 2023

@ulysses4ever I don't think that we should rename the variables now, since we don't know whether non-installable and non-upgradable are the same. This PR only resolves #8581 partially, so the comments can link to that issue. The next step is to determine whether non-installable and non-upgradable packages are treated the same, and, if they are, remove requireInstalled and related code. A clearer name for the common list of packages in this PR could be nonInstallableAndNonUpgradeablePackages.

@wismill
Copy link
Collaborator Author

wismill commented Feb 12, 2023

@grayjay I think what you propose is a good path for a transition. With good comments in the code it could be reverse if it turns out that the two lists may be different, now or in the future.

Who should we ask to get a definitive answer? I have the feeling GHC devs could enlighten us.

Should this PR be merged soon, I might get another one ready in time for Cabal 3.10 to fix #7993.

What is the release schedule?

@wismill
Copy link
Collaborator Author

wismill commented Feb 12, 2023

Some findings:

@grayjay
Copy link
Collaborator

grayjay commented Feb 23, 2023

Who should we ask to get a definitive answer? I have the feeling GHC devs could enlighten us.

GHC devs could help with creating a complete list of packages that shouldn't be reinstalled and using the correct terminology (non-upgradable vs wired-in vs boot). However, I think that having separate non-installable and non-upgradable lists is only an implementation detail of the cabal dependency solver and doesn't relate to GHC.

@gbaz
Copy link
Collaborator

gbaz commented Feb 23, 2023

Approving as a good incremental step.

@Mikolaj
Copy link
Member

Mikolaj commented Feb 23, 2023

@wismill: if you add the "squash+merge_me" label, it should automatically rebase as needed.

@wismill wismill added the squash+merge me Tell Mergify Bot to squash-merge label Feb 26, 2023
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Feb 28, 2023
@mergify mergify bot merged commit b016e59 into haskell:master Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: solver merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days squash+merge me Tell Mergify Bot to squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Try to combine lists of non-installable and non-upgradable packages
6 participants