on master help sign in
add error for when installing package that will not build
commit5a1cc18234ace947d0f012adcd4aff0b59dc092d authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 24 Jun 2019, 17:43 (7 years ago) parentafa4f13
2 files changed+29−14
builder/src/Reporting/Exit.hs+19−4 terminal/src/Install.hs+10−10
builder/src/Reporting/Exit.hs+19−4
@@ -29,6 +29,9 @@ module Reporting.Exit
2929
3030
3131import 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
3235import qualified Data.ByteString.UTF8 as BS_UTF8
3336import qualified Data.List as List
3437import qualified Data.Name as N
@@ -741,7 +744,7 @@ data Install
741744 | InstallHadSolverTrouble Solver
742745 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
743746 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
744− | InstallHasBadDetails Details
747+ | InstallHasBadDetails Pkg.Name Encode.Value
745748
746749
747750installToReport :: Install -> Help.Report
@@ -828,8 +831,20 @@ installToReport exit =
828831 , D.reflow $ "Maybe you want one of these instead?"
829832 ]
830833
831− InstallHasBadDetails _ ->
832− error "TODO InstallHasBadDetails"
834+ InstallHasBadDetails pkg outline ->
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+ ]
833848
834849
835850{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
@@ -1708,4 +1723,4 @@ replToReport problem =
17081723 corruptCacheReport
17091724
17101725 ReplBlocked ->
1711− error "TODO ReplBlocked"
1726+ corruptCacheReport
terminal/src/Install.hs+10−10
@@ -55,11 +55,11 @@ run args () =
5555 case oldOutline of
5656 Outline.App outline ->
5757 do changes <- makeAppPlan env pkg outline
58− attemptChanges root env oldOutline V.toChars changes
58+ attemptChanges root env pkg oldOutline V.toChars changes
5959
6060 Outline.Pkg outline ->
6161 do changes <- makePkgPlan env pkg outline
62− attemptChanges root env oldOutline C.toChars changes
62+ attemptChanges root env pkg oldOutline C.toChars changes
6363
6464
6565
@@ -76,14 +76,14 @@ data Changes vsn
7676type Task = Task.Task Exit.Install
7777
7878
79−attemptChanges :: FilePath -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task ()
80−attemptChanges root env oldOutline toChars changes =
79+attemptChanges :: FilePath -> Solver.Env -> Pkg.Name -> Outline.Outline -> (a -> String) -> Changes a -> Task ()
80+attemptChanges root env pkg oldOutline toChars changes =
8181 case changes of
8282 AlreadyInstalled ->
8383 Task.io $ putStrLn "It is already installed!"
8484
8585 PromoteIndirect newOutline ->
86− attemptChangesHelp root env oldOutline newOutline $
86+ attemptChangesHelp root env pkg oldOutline newOutline $
8787 D.vcat
8888 [ D.fillSep
8989 ["I","found","it","in","your","elm.json","file,"
@@ -96,7 +96,7 @@ attemptChanges root env oldOutline toChars changes =
9696 ]
9797
9898 PromoteTest newOutline ->
99− attemptChangesHelp root env oldOutline newOutline $
99+ attemptChangesHelp root env pkg oldOutline newOutline $
100100 D.vcat
101101 [ D.fillSep
102102 ["I","found","it","in","your","elm.json","file,"
@@ -113,7 +113,7 @@ attemptChanges root env oldOutline toChars changes =
113113 widths = Map.foldrWithKey (widen toChars) (Widths 0 0 0) changeDict
114114 changeDocs = Map.foldrWithKey (addChange toChars widths) (Docs [] [] []) changeDict
115115 in
116− attemptChangesHelp root env oldOutline newOutline $ D.vcat $
116+ attemptChangesHelp root env pkg oldOutline newOutline $ D.vcat $
117117 [ "Here is my plan:"
118118 , viewChangeDocs changeDocs
119119 , ""
@@ -121,9 +121,9 @@ attemptChanges root env oldOutline toChars changes =
121121 ]
122122
123123
124−attemptChangesHelp :: FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> D.Doc -> Task ()
125−attemptChangesHelp root env oldOutline newOutline question =
126− Task.eio Exit.InstallHasBadDetails $
124+attemptChangesHelp :: FilePath -> Solver.Env -> Pkg.Name -> Outline.Outline -> Outline.Outline -> D.Doc -> Task ()
125+attemptChangesHelp root env pkg oldOutline newOutline question =
126+ Task.eio (\_ -> Exit.InstallHasBadDetails pkg (Outline.encode newOutline)) $
127127 do approved <- Reporting.ask question
128128 if approved
129129 then