Skip to content

Try to combine lists of non-installable and non-upgradable packages #8581

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

Closed
grayjay opened this issue Nov 9, 2022 · 10 comments · Fixed by #8712
Closed

Try to combine lists of non-installable and non-upgradable packages #8581

grayjay opened this issue Nov 9, 2022 · 10 comments · Fixed by #8712

Comments

@grayjay
Copy link
Collaborator

grayjay commented Nov 9, 2022

Issue #8489 showed that cabal contains two separate lists of packages that cannot be installed. This issue is for determining whether the lists have the same meaning and combining them if they are redundant. #8501 synced the contents of the two lists.

One is in the solver and is described as non-installable:

-- packages that can never be installed or upgraded
-- If you change this enumeration, make sure to update the list in
-- "Distribution.Client.Dependency" as well
nonInstallable :: [PackageName]
nonInstallable =
L.map mkPackageName
[ "base"
, "ghc-bignum"
, "ghc-prim"
, "ghc-boot"
, "ghc"
, "ghci"
, "integer-gmp"
, "integer-simple"
, "template-haskell"
]

The other is in Distribution.Client.Dependency and is described as non-upgradable:

-- | Some packages are specific to a given compiler version and should never be
-- upgraded.
dontUpgradeNonUpgradeablePackages :: DepResolverParams -> DepResolverParams
dontUpgradeNonUpgradeablePackages params =
addConstraints extraConstraints params
where
extraConstraints =
[ LabeledPackageConstraint
(PackageConstraint (ScopeAnyQualifier pkgname) PackagePropertyInstalled)
ConstraintSourceNonUpgradeablePackage
| Set.notMember (mkPackageName "base") (depResolverTargets params)
-- If you change this enumeration, make sure to update the list in
-- "Distribution.Solver.Modular.Solver" as well
, pkgname <- [ mkPackageName "base"
, mkPackageName "ghc-bignum"
, mkPackageName "ghc-prim"
, mkPackageName "ghc-boot"
, mkPackageName "ghc"
, mkPackageName "ghci"
, mkPackageName "integer-gmp"
, mkPackageName "integer-simple"
, mkPackageName "template-haskell"
]
, isInstalled pkgname ]
isInstalled = not . null
. InstalledPackageIndex.lookupPackageName
(depResolverInstalledPkgIndex params)

If only one is needed, I think we should keep the one in Distribution.Client.Dependency, since it is better to make the solver more general and pass in constraints rather than hard code package names.

@wismill
Copy link
Collaborator

wismill commented Jan 12, 2023

Does somebody has this info?

Else now that the two lists are synced, we could give it a try with proper comments. It would be easy to revert and desync the two list again if there is some issue. I think this would help addressing #7993. In what module should this list go?

@Mikolaj
Copy link
Member

Mikolaj commented Jan 21, 2023

@wismill: thank you for taking interest and the willingness to contribute. I hope at some point @grayjay or @gbaz find a moment to conspire with you. If not, please ping me and I will try to find help elsewhere.

@grayjay
Copy link
Collaborator Author

grayjay commented Jan 22, 2023

@wismill I think it would be fine to try out this change and see whether the tests pass. I think that we should keep the list in Distribution.Client.Dependency. A fix for #7993 could use the ConstraintSource (ConstraintSourceNonUpgradeablePackage) to determine whether a package version is disallowed because it is not upgradable.

It may also help to add more unit tests to this test group:

, testGroup "Base and Nonupgradable" [
runTest $ mkTest dbBase "Refuse to install base without --allow-boot-library-installs" ["base"] $
solverFailure (isInfixOf "only already installed instances can be used")
, runTest $ allowBootLibInstalls $ mkTest dbBase "Install base with --allow-boot-library-installs" ["base"] $
solverSuccess [("base", 1), ("ghc-prim", 1), ("integer-gmp", 1), ("integer-simple", 1)]
, runTest $ mkTest dbNonupgrade "Refuse to install newer ghc requested by another library" ["A"] $
solverFailure (isInfixOf "rejecting: ghc-2.0.0 (constraint from non-upgradeable package requires installed instance)")
, runTest $ mkTest dbNonupgrade "Refuse to install newer ghci requested by another library" ["B"] $
solverFailure (isInfixOf "rejecting: ghci-2.0.0 (constraint from non-upgradeable package requires installed instance)")
, runTest $ mkTest dbNonupgrade "Refuse to install newer ghc-boot requested by another library" ["C"] $
solverFailure (isInfixOf "rejecting: ghc-boot-2.0.0 (constraint from non-upgradeable package requires installed instance)")
]

I think that the test "Refuse to install base without --allow-boot-library-installs" could at least be improved by testing for a larger part of the error message that rejects base. The error message may also change due to this refactoring.

@wismill
Copy link
Collaborator

wismill commented Jan 22, 2023

@grayjay Distribution.Client.Dependency is in cabal-install, which depends on cabal-install-solver. Therefore the list should be in cabal-install-solver, should not it?

@grayjay
Copy link
Collaborator Author

grayjay commented Jan 28, 2023

@wismill I think that the list should stay in Distribution.Client.Dependency, because it is better to keep the solver more general and pass in constraints on specific packages. Handling "installed" constraints similarly to other constraints that are passed to the solver also simplifies the code.

@wismill
Copy link
Collaborator

wismill commented Jan 28, 2023

@grayjay Then correct me if I am wrong, but given the package dependency we can close this issue as non-fixable.

@grayjay
Copy link
Collaborator Author

grayjay commented Jan 29, 2023

The list in Distribution.Client.Dependency is already passed into and used by the solver. The issue is that the solver uses two lists of packages (the other in Distribution.Solver.Modular.Solver), so they probably provide redundant functionality.

@grayjay
Copy link
Collaborator Author

grayjay commented Feb 28, 2023

Reopening, because the requireInstalled function can probably also be removed, because it is redundant with enforcing the installed constraints that are added in Distribution.Client.Dependency:

-- | Require installed packages.
requireInstalled :: (PN -> Bool) -> EndoTreeTrav d c

@grayjay grayjay reopened this Feb 28, 2023
@grayjay
Copy link
Collaborator Author

grayjay commented Jun 26, 2023

@wismill Are you still interested in working on this issue?

@wismill
Copy link
Collaborator

wismill commented Jul 4, 2023

@grayjay I am too busy for the moment. I cannot say when I will be available, sorry.

@mergify mergify bot closed this as completed in 9adf58c Aug 2, 2023
mergify bot added a commit that referenced this issue Aug 2, 2023
Combine non-installable and non-upgradable package lists (fixes #8581)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants