@@ -159,12 +159,10 @@ data SetupException
159
159
| SetupInfoMissingSevenz
160
160
| DockerStackExeNotFound Version Text
161
161
| UnsupportedSetupConfiguration
162
- | InvalidGhcAt (Path Abs File ) SomeException
163
162
| MSYS2NotFound Text
164
163
| UnwantedCompilerVersion
165
164
| UnwantedArchitecture
166
165
| SandboxedCompilerNotFound
167
- | CompilerNotFound [String ]
168
166
| GHCInfoNotValidUTF8 UnicodeException
169
167
| GHCInfoNotListOfPairs
170
168
| GHCInfoMissingGlobalPackageDB
@@ -256,13 +254,6 @@ instance Exception SetupException where
256
254
" Error: [S-7748]\n "
257
255
++ " Stack does not know how to install GHC on your system \
258
256
\configuration, please install manually."
259
- displayException (InvalidGhcAt compiler e) = concat
260
- [ " Error: [S-2476]\n "
261
- , " Found an invalid compiler at "
262
- , show (toFilePath compiler)
263
- , " : "
264
- , displayException e
265
- ]
266
257
displayException (MSYS2NotFound osKey) = concat
267
258
[ " Error: [S-5308]\n "
268
259
, " MSYS2 not found for "
@@ -277,11 +268,6 @@ instance Exception SetupException where
277
268
displayException SandboxedCompilerNotFound =
278
269
" Error: [S-9953]\n "
279
270
++ " Could not find sandboxed compiler."
280
- displayException (CompilerNotFound toTry) = concat
281
- [ " Error: [S-4764]\n "
282
- , " Could not find any of: "
283
- , show toTry
284
- ]
285
271
displayException (GHCInfoNotValidUTF8 e) = concat
286
272
[ " Error: [S-8668]\n "
287
273
, " GHC info is not valid UTF-8: "
@@ -407,11 +393,13 @@ data SetupPrettyException
407
393
(Path Abs Dir )
408
394
(Path Abs Dir )
409
395
(Path Abs Dir )
396
+ | InvalidGhcAt (Path Abs File ) SomeException
397
+ | ExecutableNotFound [Path Abs File ]
410
398
deriving (Show , Typeable )
411
399
412
400
instance Pretty SetupPrettyException where
413
401
pretty (GHCInstallFailed ex step cmd args wd tempDir destDir) =
414
- " [S-7441]"
402
+ " [S-7441]"
415
403
<> line
416
404
<> string (displayException ex)
417
405
<> line
@@ -442,6 +430,24 @@ instance Pretty SetupPrettyException where
442
430
, " flag."
443
431
]
444
432
<> line
433
+ pretty (InvalidGhcAt compiler e) =
434
+ " [S-2476]"
435
+ <> line
436
+ <> fillSep
437
+ [ flow " Stack considers the compiler at"
438
+ , pretty compiler
439
+ , flow " to be invalid."
440
+ ]
441
+ <> blankLine
442
+ <> flow " While assessing that compiler, Stack encountered the error:"
443
+ <> blankLine
444
+ <> ppException e
445
+ pretty (ExecutableNotFound toTry) =
446
+ " [S-4764]"
447
+ <> line
448
+ <> flow " Stack could not find any of the following executables:"
449
+ <> line
450
+ <> bulletedList (map pretty toTry)
445
451
446
452
instance Exception SetupPrettyException
447
453
@@ -1177,17 +1183,21 @@ pathsFromCompiler wc compilerBuild isSandboxed compiler =
1177
1183
suffixes = maybe id (:) msuffixWithVersion [suffixNoVersion]
1178
1184
findHelper :: (WhichCompiler -> [String ]) -> RIO env (Path Abs File )
1179
1185
findHelper getNames = do
1180
- let toTry = [ dir ++ name ++ suffix
1181
- | suffix <- suffixes, name <- getNames wc
1182
- ]
1183
- loop [] = throwIO $ CompilerNotFound toTry
1184
- loop (guessedPath': rest) = do
1185
- guessedPath <- parseAbsFile guessedPath'
1186
+ toTry <- mapM
1187
+ parseAbsFile
1188
+ [ dir ++ name ++ suffix
1189
+ | suffix <- suffixes, name <- getNames wc
1190
+ ]
1191
+ let loop [] = throwIO $ PrettyException $ ExecutableNotFound toTry
1192
+ loop (guessedPath: rest) = do
1186
1193
exists <- doesFileExist guessedPath
1187
1194
if exists
1188
1195
then pure guessedPath
1189
1196
else loop rest
1190
- logDebug $ " Looking for executable(s): " <> displayShow toTry
1197
+ prettyDebug $
1198
+ flow " Looking for executable(s):"
1199
+ <> line
1200
+ <> bulletedList (map pretty toTry)
1191
1201
loop toTry
1192
1202
pkg <- fmap GhcPkgExe $ findHelper $ \ case
1193
1203
Ghc -> [" ghc-pkg" ]
@@ -1268,7 +1278,7 @@ pathsFromCompiler wc compilerBuild isSandboxed compiler =
1268
1278
, cpGlobalDump = globalDump
1269
1279
}
1270
1280
where
1271
- onErr = throwIO . InvalidGhcAt compiler
1281
+ onErr = throwIO . PrettyException . InvalidGhcAt compiler
1272
1282
1273
1283
withCache inner = do
1274
1284
eres <- tryAny $ loadCompilerPaths compiler compilerBuild isSandboxed
0 commit comments