Skip to content

Commit

Permalink
Merge pull request #4922 from Rufflewind/master
Browse files Browse the repository at this point in the history
Tell the user that a boot package was pruned
  • Loading branch information
snoyberg authored Feb 4, 2020
2 parents aa59b3e + b5ca47c commit a7a6c35
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 @@ -1105,7 +1105,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 @@ -1117,13 +1117,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 a7a6c35

Please sign in to comment.