Skip to content

Commit ec5cf7b

Browse files
committed
Fix plan inconsistencies
1 parent 6910769 commit ec5cf7b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,16 @@ import Prelude ()
6464
import Distribution.Package
6565
( HasUnitId (..)
6666
, Package (..)
67-
, PackageId
6867
, PackageIdentifier (..)
69-
, PackageName
70-
, packageName
71-
, packageVersion
7268
)
7369
import qualified Distribution.Solver.Types.ComponentDeps as CD
7470
import Distribution.Types.Flag (nullFlagAssignment)
7571

7672
import Distribution.Client.Types
7773
( UnresolvedPkgLoc
7874
)
79-
import Distribution.Version
80-
( Version
81-
)
8275

83-
import Distribution.Solver.Types.PackagePath (PackagePath, Qualified(..))
76+
import Distribution.Solver.Types.PackagePath (PackagePath, Qualified(..), QPN)
8477
import Distribution.Solver.Types.ResolverPackage
8578
import Distribution.Solver.Types.SolverId
8679
import Distribution.Solver.Types.SolverPackage
@@ -95,6 +88,7 @@ import qualified Distribution.Compat.Graph as Graph
9588

9689

9790

91+
9892
type SolverPlanPackage = ResolverPackage UnresolvedPkgLoc
9993

10094
type SolverPlanIndex = Graph SolverPlanPackage
@@ -201,7 +195,7 @@ data SolverPlanProblem
201195
SolverPlanPackage
202196
[PackageIdentifier]
203197
| PackageCycle [SolverPlanPackage]
204-
| PackageInconsistency PackageName [(PackageIdentifier, Version)]
198+
| PackageInconsistency QPN [(SolverId, SolverId)]
205199
| PackageStateInvalid SolverPlanPackage SolverPlanPackage
206200

207201
showPlanProblem :: SolverPlanProblem -> String
@@ -222,7 +216,7 @@ showPlanProblem (PackageInconsistency name inconsistencies) =
222216
[ " package "
223217
++ prettyShow pkg
224218
++ " requires "
225-
++ prettyShow (PackageIdentifier name ver)
219+
++ prettyShow ver
226220
| (pkg, ver) <- inconsistencies
227221
]
228222
showPlanProblem (PackageStateInvalid pkg pkg') =
@@ -279,7 +273,7 @@ problems index =
279273
-- for them here.
280274
dependencyInconsistencies
281275
:: SolverPlanIndex
282-
-> [(PackageName, [(PackageIdentifier, Version)])]
276+
-> [(QPN, [(SolverId, SolverId)])]
283277
dependencyInconsistencies index =
284278
concatMap dependencyInconsistencies' subplans
285279
where
@@ -337,6 +331,8 @@ qualifications g = Map.fromListWith (<>)
337331
--
338332
-- The library roots are the set of packages with no reverse dependencies
339333
-- (no reverse library dependencies but also no reverse setup dependencies).
334+
--
335+
-- FIXME: misleading name, this includes executables too!
340336
libraryRoots :: SolverPlanIndex -> [SolverId]
341337
libraryRoots index =
342338
map (nodeKey . toPkgId) roots
@@ -364,9 +360,14 @@ setupRoots =
364360
-- distinct.
365361
dependencyInconsistencies'
366362
:: SolverPlanIndex
367-
-> [(PackageName, [(PackageIdentifier, Version)])]
363+
-> [(QPN, [(SolverId, SolverId)])]
368364
dependencyInconsistencies' index =
369-
[ (name, [(pid, packageVersion dep) | (dep, pids) <- uses, pid <- pids])
365+
[ (name,
366+
[ (sid, solverId dep)
367+
| (dep, sids) <- uses
368+
, sid <- sids
369+
]
370+
)
370371
| (name, ipid_map) <- Map.toList inverseIndex
371372
, let uses = Map.elems ipid_map
372373
, length uses > 1
@@ -376,13 +377,13 @@ dependencyInconsistencies' index =
376377
-- and each installed ID of that package
377378
-- the associated package instance
378379
-- and a list of reverse dependencies (as source IDs)
379-
inverseIndex :: Map PackageName (Map SolverId (SolverPlanPackage, [PackageId]))
380+
inverseIndex :: Map QPN (Map SolverId (SolverPlanPackage, [SolverId]))
380381
inverseIndex =
381382
Map.fromListWith
382383
(Map.unionWith (\(a, b) (_, b') -> (a, b ++ b')))
383-
[ (packageName dep, Map.fromList [(sid, (dep, [packageId pkg]))])
384+
[ (solverQPN dep, Map.fromList [(sid, (dep, [solverId pkg]))])
384385
| -- For each package @pkg@
385-
pkg <- Foldable.toList index
386+
pkg <- Foldable.toList index
386387
, -- Find out which @sid@ @pkg@ depends on
387388
sid <- CD.nonSetupDeps (resolverPackageLibDeps pkg)
388389
, -- And look up those @sid@ (i.e., @sid@ is the ID of @dep@)

0 commit comments

Comments
 (0)