Skip to content

Commit 3714975

Browse files
committed
Don't repeat suggestion when no project config
1 parent a094a85 commit 3714975

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Stack/Types/Build/Exception.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
516516
<> blankLine
517517
<> indent 2 (spacedBulletedList recommendations)
518518
where
519+
prettyUserConfig = pretty (defaultUserConfigPath stackRoot)
520+
prettyStackYaml = pretty stackYaml
521+
isScript = show prettyUserConfig == show prettyStackYaml
522+
519523
exceptions' = {- should we dedupe these somehow? nubOrd -} exceptions
520524

521525
recommendations =
@@ -539,17 +543,17 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
539543
else
540544
[ fillSep
541545
$ [ "in"
542-
, pretty (defaultUserConfigPath stackRoot)
546+
, prettyUserConfig
543547
, flow
544548
( "(global configuration)"
545549
<> if isImplicitGlobal then "," else mempty
546550
)
547551
]
548-
<> ( if isImplicitGlobal
552+
<> ( if isImplicitGlobal || isScript
549553
then []
550554
else
551555
[ "or"
552-
, pretty stackYaml
556+
, prettyStackYaml
553557
, flow "(project-level configuration),"
554558
]
555559
)
@@ -573,18 +577,19 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
573577
, style Current "base"<> "."
574578
]
575579
]
576-
| otherwise =
580+
| not isScript =
577581
[ fillSep
578582
[ style Recommendation (flow "Recommended action:")
579583
, flow "try adding the following to your"
580584
, style Shell "extra-deps"
581585
, "in"
582-
, pretty stackYaml
586+
, prettyStackYaml
583587
, "(project-level configuration):"
584588
]
585589
<> blankLine
586590
<> vsep (map pprintExtra (Map.toList extras))
587591
]
592+
| otherwise = []
588593

589594
pprintExtra (name, (version, BlobKey cabalHash cabalSize)) =
590595
let cfInfo = CFIHash cabalHash (Just cabalSize)
@@ -750,7 +755,7 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
750755
latestApplicable mversion =
751756
case mlatestApplicable of
752757
Nothing
753-
| isNothing mversion -> fillSep
758+
| isNothing mversion -> fillSep $
754759
[ flow "(no matching package and version found. Perhaps there is \
755760
\an error in the specification of a package's"
756761
, style Shell "dependencies"
@@ -765,7 +770,9 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
765770
, flow "or an omission from the"
766771
, style Shell "packages"
767772
, flow "list in"
768-
, pretty stackYaml
773+
]
774+
++ if isScript then [] else
775+
[ prettyStackYaml
769776
, flow "(project-level configuration).)"
770777
]
771778
| otherwise -> ""

0 commit comments

Comments
 (0)