on master help sign in
add error for when installing package that will not build
5a1cc18Evan Czaplicki
builder/src/Reporting/Exit.hs+19−4
@@ -29,6 +29,9 @@ module Reporting.Exit
29
29
30
30
31import qualified Data.ByteString as BS
31import qualified Data.ByteString as BS
32+import qualified Data.ByteString.Builder as B
33+import qualified Data.ByteString.Char8 as BSC
34+import qualified Data.ByteString.Lazy as LBS
32import qualified Data.ByteString.UTF8 as BS_UTF8
35import qualified Data.ByteString.UTF8 as BS_UTF8
33import qualified Data.List as List
36import qualified Data.List as List
34import qualified Data.Name as N
37import qualified Data.Name as N
@@ -741,7 +744,7 @@ data Install
741 | InstallHadSolverTrouble Solver
744 | InstallHadSolverTrouble Solver
742 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
745 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
743 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
746 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
744− | InstallHasBadDetails Details
747+ | InstallHasBadDetails Pkg.Name Encode.Value
745
748
746
749
747installToReport :: Install -> Help.Report
750installToReport :: Install -> Help.Report
@@ -828,8 +831,20 @@ installToReport exit =
828 , D.reflow $ "Maybe you want one of these instead?"
831 , D.reflow $ "Maybe you want one of these instead?"
829 ]
832 ]
830
833
831− InstallHasBadDetails _ ->
834+ InstallHasBadDetails pkg outline ->
832− error "TODO InstallHasBadDetails"
835+ Help.report "INSTALL PROBLEM" Nothing
836+ (
837+ "I found a version of " ++ Pkg.toChars pkg ++ " that claims to be compatible with\
838+ \ your existing dependencies, but I ran into an error when I tried to build it locally."
839+ )
840+ [ D.reflow $
841+ "Here is an elm.json that should reproduce the error with a bit more information:"
842+ , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromChars $
843+ map BS_UTF8.toString $ BSC.lines $ LBS.toStrict $ B.toLazyByteString $
844+ Encode.encode outline
845+ , D.reflow $
846+ "Maybe that can help figure out what is going on here."
847+ ]
833
848
834
849
835{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
850{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
@@ -1708,4 +1723,4 @@ replToReport problem =
1708 corruptCacheReport
1723 corruptCacheReport
1709
1724
1710 ReplBlocked ->
1725 ReplBlocked ->
1711− error "TODO ReplBlocked"
1726+ corruptCacheReport
terminal/src/Install.hs+10−10
@@ -55,11 +55,11 @@ run args () =
55 case oldOutline of
55 case oldOutline of
56 Outline.App outline ->
56 Outline.App outline ->
57 do changes <- makeAppPlan env pkg outline
57 do changes <- makeAppPlan env pkg outline
58− attemptChanges root env oldOutline V.toChars changes
58+ attemptChanges root env pkg oldOutline V.toChars changes
59
59
60 Outline.Pkg outline ->
60 Outline.Pkg outline ->
61 do changes <- makePkgPlan env pkg outline
61 do changes <- makePkgPlan env pkg outline
62− attemptChanges root env oldOutline C.toChars changes
62+ attemptChanges root env pkg oldOutline C.toChars changes
63
63
64
64
65
65
@@ -76,14 +76,14 @@ data Changes vsn
76type Task = Task.Task Exit.Install
76type Task = Task.Task Exit.Install
77
77
78
78
79−attemptChanges :: FilePath -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task ()
79+attemptChanges :: FilePath -> Solver.Env -> Pkg.Name -> Outline.Outline -> (a -> String) -> Changes a -> Task ()
80−attemptChanges root env oldOutline toChars changes =
80+attemptChanges root env pkg oldOutline toChars changes =
81 case changes of
81 case changes of
82 AlreadyInstalled ->
82 AlreadyInstalled ->
83 Task.io $ putStrLn "It is already installed!"
83 Task.io $ putStrLn "It is already installed!"
84
84
85 PromoteIndirect newOutline ->
85 PromoteIndirect newOutline ->
86− attemptChangesHelp root env oldOutline newOutline $
86+ attemptChangesHelp root env pkg oldOutline newOutline $
87 D.vcat
87 D.vcat
88 [ D.fillSep
88 [ D.fillSep
89 ["I","found","it","in","your","elm.json","file,"
89 ["I","found","it","in","your","elm.json","file,"
@@ -96,7 +96,7 @@ attemptChanges root env oldOutline toChars changes =
96 ]
96 ]
97
97
98 PromoteTest newOutline ->
98 PromoteTest newOutline ->
99− attemptChangesHelp root env oldOutline newOutline $
99+ attemptChangesHelp root env pkg oldOutline newOutline $
100 D.vcat
100 D.vcat
101 [ D.fillSep
101 [ D.fillSep
102 ["I","found","it","in","your","elm.json","file,"
102 ["I","found","it","in","your","elm.json","file,"
@@ -113,7 +113,7 @@ attemptChanges root env oldOutline toChars changes =
113 widths = Map.foldrWithKey (widen toChars) (Widths 0 0 0) changeDict
113 widths = Map.foldrWithKey (widen toChars) (Widths 0 0 0) changeDict
114 changeDocs = Map.foldrWithKey (addChange toChars widths) (Docs [] [] []) changeDict
114 changeDocs = Map.foldrWithKey (addChange toChars widths) (Docs [] [] []) changeDict
115 in
115 in
116− attemptChangesHelp root env oldOutline newOutline $ D.vcat $
116+ attemptChangesHelp root env pkg oldOutline newOutline $ D.vcat $
117 [ "Here is my plan:"
117 [ "Here is my plan:"
118 , viewChangeDocs changeDocs
118 , viewChangeDocs changeDocs
119 , ""
119 , ""
@@ -121,9 +121,9 @@ attemptChanges root env oldOutline toChars changes =
121 ]
121 ]
122
122
123
123
124−attemptChangesHelp :: FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> D.Doc -> Task ()
124+attemptChangesHelp :: FilePath -> Solver.Env -> Pkg.Name -> Outline.Outline -> Outline.Outline -> D.Doc -> Task ()
125−attemptChangesHelp root env oldOutline newOutline question =
125+attemptChangesHelp root env pkg oldOutline newOutline question =
126− Task.eio Exit.InstallHasBadDetails $
126+ Task.eio (\_ -> Exit.InstallHasBadDetails pkg (Outline.encode newOutline)) $
127 do approved <- Reporting.ask question
127 do approved <- Reporting.ask question
128 if approved
128 if approved
129 then
129 then