Skip to content

Commit 51da23d

Browse files
authored
Merge pull request #9148 from grayjay/issue-8581
Combine non-installable and non-upgradable package lists (fixes #8581)
2 parents 0e8f2cd + e0d283b commit 51da23d

File tree

7 files changed

+15
-60
lines changed

7 files changed

+15
-60
lines changed

cabal-install-solver/src/Distribution/Solver/Modular/Message.hs

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ showFR _ (NewPackageHasUnbuildableRequiredComponent comp dr) = " (" ++ showExpos
228228
showFR _ (PackageRequiresMissingComponent qpn comp) = " (requires " ++ showExposedComponent comp ++ " from " ++ showQPN qpn ++ ", but the component does not exist)"
229229
showFR _ (PackageRequiresPrivateComponent qpn comp) = " (requires " ++ showExposedComponent comp ++ " from " ++ showQPN qpn ++ ", but the component is private)"
230230
showFR _ (PackageRequiresUnbuildableComponent qpn comp) = " (requires " ++ showExposedComponent comp ++ " from " ++ showQPN qpn ++ ", but the component is not buildable in the current environment)"
231-
showFR _ CannotInstall = " (only already installed instances can be used)"
232231
showFR _ CannotReinstall = " (avoiding to reinstall a package with same version but new dependencies)"
233232
showFR _ NotExplicit = " (not a user-provided goal nor mentioned as a constraint, but reject-unconstrained-dependencies was set)"
234233
showFR _ Shadowed = " (shadowed by another installed package with same version)"

cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs

-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Distribution.Solver.Modular.Preference
1212
, preferLinked
1313
, preferPackagePreferences
1414
, preferReallyEasyGoalChoices
15-
, requireInstalled
1615
, onlyConstrained
1716
, sortGoals
1817
, pruneAfterFirstSuccess
@@ -318,18 +317,6 @@ enforceManualFlags pcs = go
318317
in W.mapWithKey (restrictToggling d flagConstraintValues) ts
319318
go x = x
320319

321-
-- | Require installed packages.
322-
requireInstalled :: (PN -> Bool) -> EndoTreeTrav d c
323-
requireInstalled p = go
324-
where
325-
go (PChoiceF v@(Q _ pn) rdm gr cs)
326-
| p pn = PChoiceF v rdm gr (W.mapWithKey installed cs)
327-
| otherwise = PChoiceF v rdm gr cs
328-
where
329-
installed (POption (I _ (Inst _)) _) x = x
330-
installed _ _ = Fail (varToConflictSet (P v)) CannotInstall
331-
go x = x
332-
333320
-- | Avoid reinstalls.
334321
--
335322
-- This is a tricky strategy. If a package version is installed already and the

cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

-5
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ data SolverConfig = SolverConfig {
6666
avoidReinstalls :: AvoidReinstalls,
6767
shadowPkgs :: ShadowPkgs,
6868
strongFlags :: StrongFlags,
69-
allowBootLibInstalls :: AllowBootLibInstalls,
70-
nonInstallablePackages :: [PackageName],
7169
onlyConstrained :: OnlyConstrained,
7270
maxBackjumps :: Maybe Int,
7371
enableBackjumping :: EnableBackjumping,
@@ -141,9 +139,6 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
141139
validateLinking idx .
142140
validateTree cinfo idx pkgConfigDB
143141
prunePhase = (if asBool (avoidReinstalls sc) then P.avoidReinstalls (const True) else id) .
144-
(if asBool (allowBootLibInstalls sc)
145-
then id
146-
else P.requireInstalled (`elem` nonInstallablePackages sc)) .
147142
(case onlyConstrained sc of
148143
OnlyConstrainedAll ->
149144
P.onlyConstrained pkgIsExplicit

cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ data FailReason = UnsupportedExtension Extension
110110
| PackageRequiresMissingComponent QPN ExposedComponent
111111
| PackageRequiresPrivateComponent QPN ExposedComponent
112112
| PackageRequiresUnbuildableComponent QPN ExposedComponent
113-
| CannotInstall
114113
| CannotReinstall
115114
| NotExplicit
116115
| Shadowed

cabal-install-solver/src/Distribution/Solver/Types/ConstraintSource.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data ConstraintSource =
2727
| ConstraintSourceUserTarget
2828

2929
-- | Internal requirement to use installed versions of packages like ghc-prim.
30-
| ConstraintSourceNonUpgradeablePackage
30+
| ConstraintSourceNonReinstallablePackage
3131

3232
-- | Internal constraint used by @cabal freeze@.
3333
| ConstraintSourceFreeze
@@ -64,8 +64,8 @@ showConstraintSource (ConstraintSourceProjectConfig path) =
6464
showConstraintSource (ConstraintSourceUserConfig path)= "user config " ++ path
6565
showConstraintSource ConstraintSourceCommandlineFlag = "command line flag"
6666
showConstraintSource ConstraintSourceUserTarget = "user target"
67-
showConstraintSource ConstraintSourceNonUpgradeablePackage =
68-
"non-upgradeable package"
67+
showConstraintSource ConstraintSourceNonReinstallablePackage =
68+
"non-reinstallable package"
6969
showConstraintSource ConstraintSourceFreeze = "cabal freeze"
7070
showConstraintSource ConstraintSourceConfigFlagOrTarget =
7171
"config file, command line flag, or user target"

cabal-install/src/Distribution/Client/Dependency.hs

+9-34
Original file line numberDiff line numberDiff line change
@@ -436,26 +436,18 @@ setSolverVerbosity verbosity params =
436436
}
437437

438438
-- | Some packages are specific to a given compiler version and should never be
439-
-- upgraded.
440-
dontUpgradeNonUpgradeablePackages :: DepResolverParams -> DepResolverParams
441-
dontUpgradeNonUpgradeablePackages params =
439+
-- reinstalled.
440+
dontInstallNonReinstallablePackages :: DepResolverParams -> DepResolverParams
441+
dontInstallNonReinstallablePackages params =
442442
addConstraints extraConstraints params
443443
where
444444
extraConstraints =
445445
[ LabeledPackageConstraint
446446
(PackageConstraint (ScopeAnyQualifier pkgname) PackagePropertyInstalled)
447-
ConstraintSourceNonUpgradeablePackage
448-
| Set.notMember (mkPackageName "base") (depResolverTargets params)
449-
, pkgname <- nonUpgradeablePackages
450-
, isInstalled pkgname
447+
ConstraintSourceNonReinstallablePackage
448+
| pkgname <- nonReinstallablePackages
451449
]
452450

453-
isInstalled =
454-
not
455-
. null
456-
. InstalledPackageIndex.lookupPackageName
457-
(depResolverInstalledPkgIndex params)
458-
459451
-- | The set of non-reinstallable packages includes those which cannot be
460452
-- rebuilt using a GHC installation and Hackage-published source distribution.
461453
-- There are a few reasons why this might be true:
@@ -471,15 +463,8 @@ dontUpgradeNonUpgradeablePackages params =
471463
-- * the package does not have a complete (that is, buildable) source distribution.
472464
-- For instance, some packages provided by GHC rely on files outside of the
473465
-- source tree generated by GHC's build system.
474-
--
475-
-- Note: the list of non-upgradable/non-installable packages used to be
476-
-- respectively in this module and in `Distribution.Solver.Modular.Solver`.
477-
-- Since they were kept synced, they are now combined in the following list.
478-
--
479-
-- See: https://github.com/haskell/cabal/issues/8581 and
480-
-- https://github.com/haskell/cabal/issues/9064.
481-
nonUpgradeablePackages :: [PackageName]
482-
nonUpgradeablePackages =
466+
nonReinstallablePackages :: [PackageName]
467+
nonReinstallablePackages =
483468
[ mkPackageName "base"
484469
, mkPackageName "ghc-bignum"
485470
, mkPackageName "ghc-prim"
@@ -792,12 +777,6 @@ resolveDependencies
792777
-> Solver
793778
-> DepResolverParams
794779
-> Progress String String SolverInstallPlan
795-
-- TODO: is this needed here? see dontUpgradeNonUpgradeablePackages
796-
resolveDependencies platform comp _pkgConfigDB _solver params
797-
| Set.null (depResolverTargets params) =
798-
return (validateSolverResult platform comp indGoals [])
799-
where
800-
indGoals = depResolverIndependentGoals params
801780
resolveDependencies platform comp pkgConfigDB solver params =
802781
Step (showDepResolverParams finalparams) $
803782
fmap (validateSolverResult platform comp indGoals) $
@@ -812,10 +791,6 @@ resolveDependencies platform comp pkgConfigDB solver params =
812791
noReinstalls
813792
shadowing
814793
strFlags
815-
allowBootLibs
816-
-- See comment of nonUpgradeablePackages about
817-
-- non-installable and non-upgradable packages.
818-
nonUpgradeablePackages
819794
onlyConstrained_
820795
maxBkjumps
821796
enableBj
@@ -848,7 +823,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
848823
noReinstalls
849824
shadowing
850825
strFlags
851-
allowBootLibs
826+
_allowBootLibs
852827
onlyConstrained_
853828
maxBkjumps
854829
enableBj
@@ -858,7 +833,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
858833
) =
859834
if asBool (depResolverAllowBootLibInstalls params)
860835
then params
861-
else dontUpgradeNonUpgradeablePackages params
836+
else dontInstallNonReinstallablePackages params
862837

863838
preferences :: PackageName -> PackagePreferences
864839
preferences = interpretPackagesPreference targets defpref prefs

cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,17 @@ tests =
192192
, runTest $ mkTest db12 "baseShim6" ["E"] (solverSuccess [("E", 1), ("syb", 2)])
193193
]
194194
, testGroup
195-
"Base and Nonupgradable"
195+
"Base and non-reinstallable"
196196
[ runTest $
197197
mkTest dbBase "Refuse to install base without --allow-boot-library-installs" ["base"] $
198-
solverFailure (isInfixOf "only already installed instances can be used")
198+
solverFailure (isInfixOf "rejecting: base-1.0.0 (constraint from non-reinstallable package requires installed instance)")
199199
, runTest $
200200
allowBootLibInstalls $
201201
mkTest dbBase "Install base with --allow-boot-library-installs" ["base"] $
202202
solverSuccess [("base", 1), ("ghc-prim", 1), ("integer-gmp", 1), ("integer-simple", 1)]
203203
, runTest $
204204
mkTest dbNonupgrade "Refuse to install newer ghc requested by another library" ["A"] $
205-
solverFailure (isInfixOf "rejecting: ghc-2.0.0 (constraint from non-upgradeable package requires installed instance)")
205+
solverFailure (isInfixOf "rejecting: ghc-2.0.0 (constraint from non-reinstallable package requires installed instance)")
206206
]
207207
, testGroup
208208
"reject-unconstrained"

0 commit comments

Comments
 (0)