Skip to content

cabal-install: Fix non-reinstallable package set (backport #9092) #9141

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 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions cabal-install/src/Distribution/Client/Dependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -397,24 +397,50 @@ dontUpgradeNonUpgradeablePackages params =
| 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"
]
, pkgname <- nonUpgradeablePackages
, isInstalled pkgname ]

isInstalled = not . null
. InstalledPackageIndex.lookupPackageName
(depResolverInstalledPkgIndex params)

addSourcePackages :: [UnresolvedSourcePackage]
-> DepResolverParams -> DepResolverParams
-- | The set of non-reinstallable packages includes those which cannot be
-- rebuilt using a GHC installation and Hackage-published source distribution.
-- There are a few reasons why this might be true:
--
-- * the package overrides its unit ID (e.g. with ghc's @-this-unit-id@ flag),
-- which can result in multiple indistinguishable packages (having potentially
-- different ABIs) with the same unit ID.
--
-- * the package contains definitions of wired-in declarations which tie
-- it to a particular compiler (e.g. we can't build link against
-- @base-4.18.0.0@ using GHC 9.6.1).
--
-- * the package does not have a complete (that is, buildable) source distribution.
-- For instance, some packages provided by GHC rely on files outside of the
-- source tree generated by GHC's build system.
--
-- Note: the list of non-upgradable/non-installable packages used to be
-- respectively in this module and in `Distribution.Solver.Modular.Solver`.
-- Since they were kept synced, they are now combined in the following list.
--
-- See: https://github.com/haskell/cabal/issues/8581 and
-- https://github.com/haskell/cabal/issues/9064.
nonUpgradeablePackages :: [PackageName]
nonUpgradeablePackages =
[ mkPackageName "base"
, mkPackageName "ghc-bignum"
, mkPackageName "ghc-prim"
, mkPackageName "ghc"
, mkPackageName "integer-gmp"
, mkPackageName "integer-simple"
, mkPackageName "template-haskell"
]

addSourcePackages
:: [UnresolvedSourcePackage]
-> DepResolverParams
-> DepResolverParams
addSourcePackages pkgs params =
params {
depResolverSourcePkgIndex =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ tests = [
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)")
]
, testGroup "reject-unconstrained" [
runTest $ onlyConstrained $ mkTest db12 "missing syb" ["E"] $
Expand Down Expand Up @@ -1132,14 +1128,8 @@ dbBase = [
dbNonupgrade :: ExampleDb
dbNonupgrade = [
Left $ exInst "ghc" 1 "ghc-1" []
, Left $ exInst "ghci" 1 "ghci-1" []
, Left $ exInst "ghc-boot" 1 "ghc-boot-1" []
, Right $ exAv "ghc" 2 []
, Right $ exAv "ghci" 2 []
, Right $ exAv "ghc-boot" 2 []
, Right $ exAv "A" 1 [ExFix "ghc" 2]
, Right $ exAv "B" 1 [ExFix "ghci" 2]
, Right $ exAv "C" 1 [ExFix "ghc-boot" 2]
]

db13 :: ExampleDb
Expand Down