Skip to content

Commit

Permalink
Merge pull request #8628 from lf-/jadel/t8484
Browse files Browse the repository at this point in the history
TargetSelector: Include a hint in the error message for internal error
  • Loading branch information
mergify[bot] authored Jan 19, 2023
2 parents fff7a98 + 58bc9c7 commit a78d77b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions cabal-install/src/Distribution/Client/TargetSelector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -713,21 +713,26 @@ reportTargetSelectorProblems verbosity problems = do
case [ (t, m, ms) | MatchingInternalError t m ms <- problems ] of
[] -> return ()
((target, originalMatch, renderingsAndMatches):_) ->
die' verbosity $ "Internal error in target matching. It should always "
++ "be possible to find a syntax that's sufficiently qualified to "
++ "give an unambiguous match. However when matching '"
++ showTargetString target ++ "' we found "
++ showTargetSelector originalMatch
++ " (" ++ showTargetSelectorKind originalMatch ++ ") which does "
++ "not have an unambiguous syntax. The possible syntax and the "
++ "targets they match are as follows:\n"
die' verbosity $ "Internal error in target matching: could not make an "
++ "unambiguous fully qualified target selector for '"
++ showTargetString target ++ "'.\n"
++ "We made the target '" ++ showTargetSelector originalMatch ++ "' ("
++ showTargetSelectorKind originalMatch ++ ") that was expected to "
++ "be unambiguous but matches the following targets:\n"
++ unlines
[ "'" ++ showTargetString rendering ++ "' which matches "
++ intercalate ", "
[ "'" ++ showTargetString rendering ++ "', matching:"
++ concatMap ("\n - " ++)
[ showTargetSelector match ++
" (" ++ showTargetSelectorKind match ++ ")"
| match <- matches ]
| (rendering, matches) <- renderingsAndMatches ]
++ "\nNote: Cabal expects to be able to make a single fully "
++ "qualified name for a target or provide a more specific error. "
++ "Our failure to do so is a bug in cabal. "
++ "Tracking issue: https://github.com/haskell/cabal/issues/8684"
++ "\n\nHint: this may be caused by trying to build a package that "
++ "exists in the project directory but is missing from "
++ "the 'packages' stanza in your cabal project file."

case [ (t, e, g) | TargetSelectorExpected t e g <- problems ] of
[] -> return ()
Expand Down

0 comments on commit a78d77b

Please sign in to comment.