From b5ca47c575f8f3a45b46b265dca81518a090e245 Mon Sep 17 00:00:00 2001 From: Phil Ruffwind Date: Sat, 29 Jun 2019 17:07:42 -0700 Subject: [PATCH] Tell the user that a boot package was pruned Fixes #4897. --- src/Stack/Build/ConstructPlan.hs | 25 +++++++++++++------ .../tests/4897-boot-package-pruned/Main.hs | 16 ++++++++++++ .../files/directory/directory.cabal | 8 ++++++ .../files/files.cabal | 8 ++++++ .../4897-boot-package-pruned/files/stack.yaml | 3 +++ 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 test/integration/tests/4897-boot-package-pruned/Main.hs create mode 100644 test/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal create mode 100644 test/integration/tests/4897-boot-package-pruned/files/files.cabal create mode 100644 test/integration/tests/4897-boot-package-pruned/files/stack.yaml diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index 54f0c548aa..bdca7e9b77 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -1109,7 +1109,7 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted' prunedGlobalDe let prunedDeps = map (style Current . fromString . packageNameString) pruned in Just $ flow "Can't use GHC boot package" <+> (style Current . fromString . packageNameString $ name) <+> - flow "when it has an overriden dependency, " <+> + flow "when it has an overridden dependency (issue #4510);" <+> flow "you need to add the following as explicit dependencies to the project:" <+> line <+> encloseSep "" "" ", " prunedDeps | otherwise = Just $ flow "Unknown package:" <+> (style Current . fromString . packageNameString $ name) @@ -1121,13 +1121,22 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted' prunedGlobalDe pprintFlag (name, False) = "-" <> fromString (flagNameString name) pprintDep (name, (range, mlatestApplicable, badDep)) = case badDep of - NotInBuildPlan -> Just $ - style Error (fromString $ packageNameString name) <+> - align ((if range == Cabal.anyVersion - then flow "needed" - else flow "must match" <+> goodRange) <> "," <> softline <> - flow "but the stack configuration has no specified version" <+> - latestApplicable Nothing) + NotInBuildPlan + | name `elem` fold prunedGlobalDeps -> Just $ + style Error (fromString $ packageNameString name) <+> + align ((if range == Cabal.anyVersion + then flow "needed" + else flow "must match" <+> goodRange) <> "," <> softline <> + flow "but this GHC boot package has been pruned (issue #4510);" <+> + flow "you need to add the package explicitly to extra-deps" <+> + latestApplicable Nothing) + | otherwise -> Just $ + style Error (fromString $ packageNameString name) <+> + align ((if range == Cabal.anyVersion + then flow "needed" + else flow "must match" <+> goodRange) <> "," <> softline <> + flow "but the stack configuration has no specified version" <+> + latestApplicable Nothing) -- TODO: For local packages, suggest editing constraints DependencyMismatch version -> Just $ (style Error . fromString . packageIdentifierString) (PackageIdentifier name version) <+> diff --git a/test/integration/tests/4897-boot-package-pruned/Main.hs b/test/integration/tests/4897-boot-package-pruned/Main.hs new file mode 100644 index 0000000000..7ba05377d9 --- /dev/null +++ b/test/integration/tests/4897-boot-package-pruned/Main.hs @@ -0,0 +1,16 @@ +import Control.Monad (unless) +import Data.List (isInfixOf) +import StackTest + +planFailure :: String +planFailure = + "but this GHC boot package has been pruned (issue #4510);" + +main :: IO () +main = do + stackErrStderr ["build"] (expectMessage planFailure) + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) + (error $ "Expected an error: \n" ++ show msg) diff --git a/test/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal b/test/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal new file mode 100644 index 0000000000..78abfda5cf --- /dev/null +++ b/test/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal @@ -0,0 +1,8 @@ +name: directory +version: 1.3.3.0 +build-type: Simple +cabal-version: >=1.10 + +library + build-depends: base + default-language: Haskell2010 diff --git a/test/integration/tests/4897-boot-package-pruned/files/files.cabal b/test/integration/tests/4897-boot-package-pruned/files/files.cabal new file mode 100644 index 0000000000..fd7c274440 --- /dev/null +++ b/test/integration/tests/4897-boot-package-pruned/files/files.cabal @@ -0,0 +1,8 @@ +name: files +version: 0.1.0.0 +build-type: Simple +cabal-version: >=1.10 + +library + build-depends: base, directory, process + default-language: Haskell2010 diff --git a/test/integration/tests/4897-boot-package-pruned/files/stack.yaml b/test/integration/tests/4897-boot-package-pruned/files/stack.yaml new file mode 100644 index 0000000000..4a1ebfdd38 --- /dev/null +++ b/test/integration/tests/4897-boot-package-pruned/files/stack.yaml @@ -0,0 +1,3 @@ +resolver: lts-13.26 +packages: [.] +extra-deps: [./directory]