Skip to content

Commit

Permalink
Tell the user that a boot package was pruned
Browse files Browse the repository at this point in the history
  • Loading branch information
Rufflewind committed Jul 21, 2019
1 parent da6c1a4 commit b5ca47c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) <+>
Expand Down
16 changes: 16 additions & 0 deletions test/integration/tests/4897-boot-package-pruned/Main.hs
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolver: lts-13.26
packages: [.]
extra-deps: [./directory]

0 comments on commit b5ca47c

Please sign in to comment.