Skip to content

Commit 2fd35a3

Browse files
committed
Give a little more information on dependency cycle failures
1 parent e5fcfe5 commit 2fd35a3

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Stack/Build/ConstructPlan.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,13 @@ addPackageDeps treatAsDep package = do
624624
let bd =
625625
case e of
626626
UnknownPackage name -> assert (name == depname) NotInBuildPlan
627-
_ -> Couldn'tResolveItsDependencies (packageVersion package)
627+
DependencyCycleDetected names -> BDDependencyCycleDetected names
628+
-- ultimately we won't show any
629+
-- information on this to the user, we'll
630+
-- allow the dependency failures alone to
631+
-- display to avoid spamming the user too
632+
-- much
633+
DependencyPlanFailures _ _ -> Couldn'tResolveItsDependencies (packageVersion package)
628634
mlatestApplicable <- getLatestApplicableVersionAndRev
629635
return $ Left (depname, (range, mlatestApplicable, bd))
630636
Right adr | depType == AsLibrary && not (adrHasLibrary adr) ->
@@ -918,6 +924,7 @@ data BadDependency
918924
| DependencyMismatch Version
919925
| HasNoLibrary
920926
-- ^ See description of 'DepType'
927+
| BDDependencyCycleDetected ![PackageName]
921928
deriving (Typeable, Eq, Ord, Show)
922929

923930
-- TODO: Consider intersecting version ranges for multiple deps on a
@@ -1056,6 +1063,9 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted =
10561063
HasNoLibrary -> Just $
10571064
style Error (display name) <+>
10581065
align (flow "is a library dependency, but the package provides no library")
1066+
BDDependencyCycleDetected names -> Just $
1067+
style Error (display name) <+>
1068+
align (flow $ "dependency cycle detected: " ++ intercalate ", " (map packageNameString names))
10591069
where
10601070
goodRange = style Good (fromString (Cabal.display range))
10611071
latestApplicable mversion =

0 commit comments

Comments
 (0)