diff --git a/Cabal/Distribution/Backpack/ComponentsGraph.hs b/Cabal/Distribution/Backpack/ComponentsGraph.hs index f3166710a34..b086f68d79b 100644 --- a/Cabal/Distribution/Backpack/ComponentsGraph.hs +++ b/Cabal/Distribution/Backpack/ComponentsGraph.hs @@ -89,9 +89,10 @@ componentsGraphToList = map (\(N c _ cs) -> (c, cs)) . Graph.revTopSort -- | Error message when there is a cycle; takes the SCC of components. -componentCycleMsg :: [ComponentName] -> Doc -componentCycleMsg cnames = - text $ "Components in the package depend on each other in a cyclic way:\n " - ++ intercalate " depends on " +componentCycleMsg :: PackageIdentifier -> [ComponentName] -> Doc +componentCycleMsg pn cnames = + text "Components in the package" <+> pretty pn <+> text "depend on each other in a cyclic way:" + $$ + text (intercalate " depends on " [ "'" ++ showComponentName cname ++ "'" - | cname <- cnames ++ maybeToList (safeHead cnames) ] + | cname <- cnames ++ maybeToList (safeHead cnames) ]) diff --git a/Cabal/Distribution/Backpack/Configure.hs b/Cabal/Distribution/Backpack/Configure.hs index 62f5e5462ce..e2a75946d37 100644 --- a/Cabal/Distribution/Backpack/Configure.hs +++ b/Cabal/Distribution/Backpack/Configure.hs @@ -78,7 +78,7 @@ configureComponentLocalBuildInfos -- NB: In single component mode, this returns a *single* component. -- In this graph, the graph is NOT closed. graph0 <- case mkComponentsGraph enabled pkg_descr of - Left ccycle -> dieProgress (componentCycleMsg ccycle) + Left ccycle -> dieProgress (componentCycleMsg (package pkg_descr) ccycle) Right g -> return (componentsGraphToList g) infoProgress $ hang (text "Source component graph:") 4 (dispComponentsWithDeps graph0) diff --git a/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.cabal.out b/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.cabal.out index 2097c26f9c4..16840243da9 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.cabal.out @@ -1,5 +1,5 @@ # Setup configure Configuring DepCycle-1.0... Error: - Components in the package depend on each other in a cyclic way: - 'library 'bar'' depends on 'library 'foo'' depends on 'library 'bar'' + Components in the package DepCycle-1.0 depend on each other in a cyclic way: + 'library 'bar'' depends on 'library 'foo'' depends on 'library 'bar'' diff --git a/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.out b/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.out index 2097c26f9c4..16840243da9 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.out +++ b/cabal-testsuite/PackageTests/BuildDeps/DepCycle/setup.out @@ -1,5 +1,5 @@ # Setup configure Configuring DepCycle-1.0... Error: - Components in the package depend on each other in a cyclic way: - 'library 'bar'' depends on 'library 'foo'' depends on 'library 'bar'' + Components in the package DepCycle-1.0 depend on each other in a cyclic way: + 'library 'bar'' depends on 'library 'foo'' depends on 'library 'bar'' diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Bar.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Bar.hs new file mode 100644 index 00000000000..9d63afd9746 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Bar.hs @@ -0,0 +1 @@ +module Bar where diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Foo.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Foo.hs new file mode 100644 index 00000000000..efbf93bbde8 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/Foo.hs @@ -0,0 +1 @@ +module Foo where diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.out new file mode 100644 index 00000000000..274d492cb51 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.out @@ -0,0 +1,5 @@ +# cabal v2-build +Resolving dependencies... +Error: + Dependency cycle between the following components: library + In the inplace package 'issue-6894' diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.project b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.project new file mode 100644 index 00000000000..e6fdbadb439 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.test.hs new file mode 100644 index 00000000000..2fac6fcfc10 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.test.hs @@ -0,0 +1,3 @@ +import Test.Cabal.Prelude +main = cabalTest $ + fails $ cabal "v2-build" ["issue"] diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/issue.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/issue.cabal new file mode 100644 index 00000000000..3d9244d1ad2 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/issue.cabal @@ -0,0 +1,13 @@ +cabal-version: 3.0 +name: issue +version: 6894 + +library + default-language: Haskell2010 + build-depends: base, issue:sublib + exposed-modules: Foo + +library sublib + default-language: Haskell2010 + build-depends: base + exposed-modules: Bar diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.cabal.out new file mode 100644 index 00000000000..c2f87fcf4e6 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.cabal.out @@ -0,0 +1,7 @@ +# Setup configure +Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660) +Configuring issue-6894... +Error: + Components in the package issue-6894 depend on each other in a cyclic way: + 'library' depends on 'library' +# Setup build diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.out b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.out new file mode 100644 index 00000000000..c2f87fcf4e6 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.out @@ -0,0 +1,7 @@ +# Setup configure +Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660) +Configuring issue-6894... +Error: + Components in the package issue-6894 depend on each other in a cyclic way: + 'library' depends on 'library' +# Setup build diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.test.hs new file mode 100644 index 00000000000..d92ad6d8d45 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6894/setup.test.hs @@ -0,0 +1,3 @@ +import Test.Cabal.Prelude +main = setupAndCabalTest $ do + fails $ setup_build []