on master help sign in
add error message when dependencies do not build
22e7413Evan Czaplicki
builder/src/Elm/Details.hs+20−21
@@ -17,9 +17,11 @@ import Control.Concurrent (forkIO)
17import Control.Concurrent.MVar (MVar, newEmptyMVar, newMVar, putMVar, readMVar, takeMVar)
17import Control.Concurrent.MVar (MVar, newEmptyMVar, newMVar, putMVar, readMVar, takeMVar)
18import Control.Monad (liftM, liftM2, liftM4)
18import Control.Monad (liftM, liftM2, liftM4)
19import Data.Binary (Binary, get, put, getWord8, putWord8)
19import Data.Binary (Binary, get, put, getWord8, putWord8)
20+import qualified Data.Either as Either
20import qualified Data.Map as Map
21import qualified Data.Map as Map
21import qualified Data.Map.Utils as Map
22import qualified Data.Map.Utils as Map
22import qualified Data.Map.Merge.Strict as Map
23import qualified Data.Map.Merge.Strict as Map
24+import qualified Data.Maybe as Maybe
23import qualified Data.Name as Name
25import qualified Data.Name as Name
24import qualified Data.NonEmptyList as NE
26import qualified Data.NonEmptyList as NE
25import qualified Data.OneOrMore as OneOrMore
27import qualified Data.OneOrMore as OneOrMore
@@ -294,8 +296,10 @@ verifyDependencies env@(Env key root _ _ _ _) time outline solution directDeps =
294 putMVar mvar mvars
296 putMVar mvar mvars
295 deps <- traverse readMVar mvars
297 deps <- traverse readMVar mvars
296 case sequence deps of
298 case sequence deps of
297− Left problem ->
299+ Left _ ->
298− error "TODO verifyDependencies" problem
300+ do home <- Stuff.getElmHome
301+ return $ Left $ Exit.DetailsBadDeps home $
302+ Maybe.catMaybes $ Either.lefts $ Map.elems deps
299
303
300 Right artifacts ->
304 Right artifacts ->
301 let
305 let
@@ -346,13 +350,7 @@ data Artifacts =
346
350
347
351
348type Dep =
352type Dep =
349− Either Problem Artifacts
353+ Either (Maybe Exit.DetailsBadDep) Artifacts
350−
351−
352−data Problem
353− = BadDownload Exit.PackageProblem
354− | BadBuild
355− | BadDependency
356
354
357
355
358verifyDep :: Env -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Map.Map Pkg.Name Solver.Details -> Pkg.Name -> Solver.Details -> IO Dep
356verifyDep :: Env -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Map.Map Pkg.Name Solver.Details -> Pkg.Name -> Solver.Details -> IO Dep
@@ -367,23 +365,23 @@ verifyDep (Env key _ cache manager _ _) depsMVar solution pkg details@(Solver.De
367 maybeCache <- File.readBinary (Stuff.package cache pkg vsn </> "artifacts.dat")
365 maybeCache <- File.readBinary (Stuff.package cache pkg vsn </> "artifacts.dat")
368 case maybeCache of
366 case maybeCache of
369 Nothing ->
367 Nothing ->
370− build key cache depsMVar pkg details (Set.singleton fingerprint)
368+ build key cache depsMVar pkg details fingerprint Set.empty
371
369
372 Just (ArtifactCache fingerprints artifacts) ->
370 Just (ArtifactCache fingerprints artifacts) ->
373 if Set.member fingerprint fingerprints
371 if Set.member fingerprint fingerprints
374 then Reporting.report key Reporting.DBuilt >> return (Right artifacts)
372 then Reporting.report key Reporting.DBuilt >> return (Right artifacts)
375− else build key cache depsMVar pkg details (Set.insert fingerprint fingerprints)
373+ else build key cache depsMVar pkg details fingerprint fingerprints
376 else
374 else
377 do Reporting.report key Reporting.DRequested
375 do Reporting.report key Reporting.DRequested
378 result <- downloadPackage cache manager pkg vsn
376 result <- downloadPackage cache manager pkg vsn
379 case result of
377 case result of
380− Left p ->
378+ Left problem ->
381 do Reporting.report key (Reporting.DFailed pkg vsn)
379 do Reporting.report key (Reporting.DFailed pkg vsn)
382− return (Left (BadDownload p))
380+ return $ Left $ Just $ Exit.BD_BadDownload pkg vsn problem
383
381
384 Right () ->
382 Right () ->
385 do Reporting.report key (Reporting.DReceived pkg vsn)
383 do Reporting.report key (Reporting.DReceived pkg vsn)
386− build key cache depsMVar pkg details (Set.singleton fingerprint)
384+ build key cache depsMVar pkg details fingerprint Set.empty
387
385
388
386
389
387
@@ -405,17 +403,17 @@ type Fingerprint =
405-- BUILD
403-- BUILD
406
404
407
405
408−build :: Reporting.DKey -> Stuff.PackageCache -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Pkg.Name -> Solver.Details -> Set.Set Fingerprint -> IO Dep
406+build :: Reporting.DKey -> Stuff.PackageCache -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Pkg.Name -> Solver.Details -> Fingerprint -> Set.Set Fingerprint -> IO Dep
409−build key cache depsMVar pkg (Solver.Details vsn _) fingerprints =
407+build key cache depsMVar pkg (Solver.Details vsn _) f fs =
410 do eitherOutline <- Outline.read (Stuff.package cache pkg vsn)
408 do eitherOutline <- Outline.read (Stuff.package cache pkg vsn)
411 case eitherOutline of
409 case eitherOutline of
412 Left _ ->
410 Left _ ->
413 do Reporting.report key Reporting.DBroken
411 do Reporting.report key Reporting.DBroken
414− return (Left BadBuild)
412+ return $ Left $ Just $ Exit.BD_BadBuild pkg vsn f
415
413
416 Right (Outline.App _) ->
414 Right (Outline.App _) ->
417 do Reporting.report key Reporting.DBroken
415 do Reporting.report key Reporting.DBroken
418− return (Left BadBuild)
416+ return $ Left $ Just $ Exit.BD_BadBuild pkg vsn f
419
417
420 Right (Outline.Pkg (Outline.PkgOutline _ _ _ _ exposed deps _ _)) ->
418 Right (Outline.Pkg (Outline.PkgOutline _ _ _ _ exposed deps _ _)) ->
421 do allDeps <- readMVar depsMVar
419 do allDeps <- readMVar depsMVar
@@ -423,7 +421,7 @@ build key cache depsMVar pkg (Solver.Details vsn _) fingerprints =
423 case sequence directDeps of
421 case sequence directDeps of
424 Left _ ->
422 Left _ ->
425 do Reporting.report key Reporting.DBroken
423 do Reporting.report key Reporting.DBroken
426− return (Left BadDependency)
424+ return $ Left $ Nothing
427
425
428 Right directArtifacts ->
426 Right directArtifacts ->
429 do let src = Stuff.package cache pkg vsn </> "src"
427 do let src = Stuff.package cache pkg vsn </> "src"
@@ -438,7 +436,7 @@ build key cache depsMVar pkg (Solver.Details vsn _) fingerprints =
438 case sequence maybeStatuses of
436 case sequence maybeStatuses of
439 Nothing ->
437 Nothing ->
440 do Reporting.report key Reporting.DBroken
438 do Reporting.report key Reporting.DBroken
441− return (Left BadBuild)
439+ return $ Left $ Just $ Exit.BD_BadBuild pkg vsn f
442
440
443 Just statuses ->
441 Just statuses ->
444 do rmvar <- newEmptyMVar
442 do rmvar <- newEmptyMVar
@@ -448,7 +446,7 @@ build key cache depsMVar pkg (Solver.Details vsn _) fingerprints =
448 case sequence maybeResults of
446 case sequence maybeResults of
449 Nothing ->
447 Nothing ->
450 do Reporting.report key Reporting.DBroken
448 do Reporting.report key Reporting.DBroken
451− return (Left BadBuild)
449+ return $ Left $ Just $ Exit.BD_BadBuild pkg vsn f
452
450
453 Just results ->
451 Just results ->
454 let
452 let
@@ -456,6 +454,7 @@ build key cache depsMVar pkg (Solver.Details vsn _) fingerprints =
456 ifaces = gatherInterfaces exposedDict results
454 ifaces = gatherInterfaces exposedDict results
457 objects = gatherObjects results
455 objects = gatherObjects results
458 artifacts = Artifacts ifaces objects
456 artifacts = Artifacts ifaces objects
457+ fingerprints = Set.insert f fs
459 in
458 in
460 do writeDocs cache pkg vsn docsStatus results
459 do writeDocs cache pkg vsn docsStatus results
461 File.writeBinary path (ArtifactCache fingerprints artifacts)
460 File.writeBinary path (ArtifactCache fingerprints artifacts)
builder/src/Reporting/Exit.hs+47−3
@@ -14,6 +14,7 @@ module Reporting.Exit
14 , Outline(..)
14 , Outline(..)
15 , OutlineProblem(..)
15 , OutlineProblem(..)
16 , Details(..)
16 , Details(..)
17+ , DetailsBadDep(..)
17 , PackageProblem(..)
18 , PackageProblem(..)
18 , RegistryProblem(..)
19 , RegistryProblem(..)
19 , BuildProblem(..)
20 , BuildProblem(..)
@@ -34,6 +35,7 @@ import qualified Data.ByteString.Char8 as BSC
34import qualified Data.ByteString.Lazy as LBS
35import qualified Data.ByteString.Lazy as LBS
35import qualified Data.ByteString.UTF8 as BS_UTF8
36import qualified Data.ByteString.UTF8 as BS_UTF8
36import qualified Data.List as List
37import qualified Data.List as List
38+import qualified Data.Map as Map
37import qualified Data.Name as N
39import qualified Data.Name as N
38import qualified Data.NonEmptyList as NE
40import qualified Data.NonEmptyList as NE
39import qualified Network.HTTP.Client as HTTP
41import qualified Network.HTTP.Client as HTTP
@@ -1194,7 +1196,12 @@ data Details
1194 | DetailsHandEditedDependencies
1196 | DetailsHandEditedDependencies
1195 | DetailsBadOutline Outline
1197 | DetailsBadOutline Outline
1196 | DetailsCannotGetRegistry RegistryProblem
1198 | DetailsCannotGetRegistry RegistryProblem
1199+ | DetailsBadDeps FilePath [DetailsBadDep]
1200+
1201+
1202+data DetailsBadDep
1197− | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
1203+ = BD_BadDownload Pkg.Name V.Version PackageProblem
1204+ | BD_BadBuild Pkg.Name V.Version (Map.Map Pkg.Name V.Version)
1198
1205
1199
1206
1200toDetailsReport :: Details -> Help.Report
1207toDetailsReport :: Details -> Help.Report
@@ -1275,8 +1282,45 @@ toDetailsReport details =
1275 toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
1282 toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
1276 "I need the list of published packages to verify your dependencies"
1283 "I need the list of published packages to verify your dependencies"
1277
1284
1278− DetailsCannotBuildPackage pkg vsn problem ->
1285+ DetailsBadDeps cacheDir deps ->
1286+ case deps of
1287+ [] ->
1288+ Help.report "PROBLEM BUILDING DEPENDENCIES" Nothing
1289+ "I am not sure what is going wrong though."
1290+ [ D.reflow $
1291+ "I would try deleting the " ++ cacheDir ++ " and elm-stuff/ directories, then\
1292+ \ trying to build again. That will work if some cached files got corrupted\
1293+ \ somehow."
1294+ , D.reflow $
1295+ "If that does not work, go to https://elm-lang.org/community and ask for\
1296+ \ help. This is a weird case!"
1297+ ]
1298+
1299+ d:_ ->
1300+ case d of
1301+ BD_BadDownload pkg vsn packageProblem ->
1279− toPackageProblemReport pkg vsn problem
1302+ toPackageProblemReport pkg vsn packageProblem
1303+
1304+ BD_BadBuild pkg vsn fingerprint ->
1305+ Help.report "PROBLEM BUILDING DEPENDENCIES" Nothing
1306+ "I ran into a compilation error when trying to build the following package:"
1307+ [ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg ++ " " ++ V.toChars vsn
1308+ , D.reflow $
1309+ "This probably means it has package constraints that are too wide. It may be\
1310+ \ possible to tweak your elm.json to avoid the root problem as a stopgap. Head\
1311+ \ over to https://elm-lang.org/community to get help figuring out how to take\
1312+ \ this path!"
1313+ , D.toSimpleNote $
1314+ "To help with the root problem, please report this to the package author along\
1315+ \ with the following information:"
1316+ , D.indent 4 $ D.vcat $
1317+ map (\(p,v) -> D.fromChars $ Pkg.toChars p ++ " " ++ V.toChars v) $
1318+ Map.toList fingerprint
1319+ , D.reflow $
1320+ "If you want to help out even more, try building the package locally. That should\
1321+ \ give you much more specific information about why this package is failing to\
1322+ \ build, which will in turn make it easier for the package author to fix it!"
1323+ ]
1280
1324
1281
1325
1282
1326