Skip to content

Don't repeat suggestion when no project config #6602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Stack/Types/Build/Exception.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
<> blankLine
<> indent 2 (spacedBulletedList recommendations)
where
prettyUserConfig = pretty (defaultUserConfigPath stackRoot)
prettyStackYaml = pretty stackYaml
isScript = show prettyUserConfig == show prettyStackYaml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpilgrem I don't know under what circumstances this might be true when not a script.


exceptions' = {- should we dedupe these somehow? nubOrd -} exceptions

recommendations =
Expand All @@ -539,17 +543,17 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
else
[ fillSep
$ [ "in"
, pretty (defaultUserConfigPath stackRoot)
, prettyUserConfig
, flow
( "(global configuration)"
<> if isImplicitGlobal then "," else mempty
)
]
<> ( if isImplicitGlobal
<> ( if isImplicitGlobal || isScript
then []
else
[ "or"
, pretty stackYaml
, prettyStackYaml
, flow "(project-level configuration),"
]
)
Expand All @@ -573,18 +577,19 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
, style Current "base"<> "."
]
]
| otherwise =
| not isScript =
[ fillSep
[ style Recommendation (flow "Recommended action:")
, flow "try adding the following to your"
, style Shell "extra-deps"
, "in"
, pretty stackYaml
, prettyStackYaml
, "(project-level configuration):"
]
<> blankLine
<> vsep (map pprintExtra (Map.toList extras))
]
| otherwise = []

pprintExtra (name, (version, BlobKey cabalHash cabalSize)) =
let cfInfo = CFIHash cabalHash (Just cabalSize)
Expand Down Expand Up @@ -750,7 +755,7 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
latestApplicable mversion =
case mlatestApplicable of
Nothing
| isNothing mversion -> fillSep
| isNothing mversion -> fillSep $
[ flow "(no matching package and version found. Perhaps there is \
\an error in the specification of a package's"
, style Shell "dependencies"
Expand All @@ -765,7 +770,9 @@ pprintExceptions exceptions stackYaml stackRoot isImplicitGlobal parentMap wante
, flow "or an omission from the"
, style Shell "packages"
, flow "list in"
, pretty stackYaml
]
++ if isScript then [] else
[ prettyStackYaml
, flow "(project-level configuration).)"
]
| otherwise -> ""
Expand Down
Loading