on master help sign in
add error messages when `elm install` cannot find solution
a6fda62Evan Czaplicki
builder/src/Reporting/Exit.hs+70−31
@@ -741,8 +741,10 @@ data Install
741 | InstallBadOutline Outline
741 | InstallBadOutline Outline
742 | InstallBadRegistry RegistryProblem
742 | InstallBadRegistry RegistryProblem
743 | InstallNoArgs FilePath
743 | InstallNoArgs FilePath
744− | InstallNoOnlineSolution
744+ | InstallNoOnlineAppSolution Pkg.Name
745− | InstallNoOfflineSolution
745+ | InstallNoOfflineAppSolution Pkg.Name
746+ | InstallNoOnlinePkgSolution Pkg.Name
747+ | InstallNoOfflinePkgSolution Pkg.Name
746 | InstallHadSolverTrouble Solver
748 | InstallHadSolverTrouble Solver
747 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
749 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
748 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
750 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
@@ -789,18 +791,75 @@ installToReport exit =
789 ]
791 ]
790 ]
792 ]
791
793
792− InstallNoOnlineSolution ->
794+ InstallNoOnlineAppSolution pkg ->
793− Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO recommend using solver in `elm reactor`
795+ Help.report "CANNOT FIND COMPATIBLE VERSION" (Just "elm.json")
794− "This usually happens if you try to modify dependency constraints by\
796+ (
795− \ hand. I recommend deleting any dependency you added recently (or all\
797+ "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
796− \ of them if things are bad) and then adding them again with:"
798+ \ with your existing dependencies."
797− [ D.indent 4 $ D.green "elm install"
799+ )
800+ [ D.reflow $
801+ "I checked all the published versions. When that failed, I tried to find any\
802+ \ compatible combination of these packages, even if it meant changing all your\
803+ \ existing dependencies! That did not work either!"
798 , D.reflow $
804 , D.reflow $
799− "And do not be afaid to ask for help on Slack if you get stuck!"
805+ "This is most likely to happen when a package is not upgraded yet. Maybe a new\
806+ \ version of Elm came out recently? Maybe a common package was changed recently?\
807+ \ Maybe a better package came along, so there was no need to upgrade this one?\
808+ \ Try asking around https://elm-lang.org/community to learn what might be going on\
809+ \ with this package."
810+ , D.toSimpleNote $
811+ "Whatever the case, please be kind to the relevant package authors! Having\
812+ \ friendly interactions with users is great motivation, and conversely, getting\
813+ \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
814+ \ authors are humans with families, friends, jobs, vacations, responsibilities,\
815+ \ goals, etc. They face obstacles outside of their technical work you will never\
816+ \ know about, so please assume the best and try to be patient and supportive!"
800 ]
817 ]
801
818
802− InstallNoOfflineSolution ->
819+ InstallNoOfflineAppSolution pkg ->
803− error "TODO InstallNoOfflineSolution"
820+ Help.report "CANNOT FIND COMPATIBLE VERSION LOCALLY" (Just "elm.json")
821+ (
822+ "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
823+ \ with your existing dependencies."
824+ )
825+ [ D.reflow $
826+ "I was not able to connect to https://package.elm-lang.org/ though, so I was only\
827+ \ able to look through packages that you have downloaded in the past."
828+ , D.reflow $
829+ "Try again later when you have internet!"
830+ ]
831+
832+ InstallNoOnlinePkgSolution pkg ->
833+ Help.report "CANNOT FIND COMPATIBLE VERSION" (Just "elm.json")
834+ (
835+ "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
836+ \ with your existing constraints."
837+ )
838+ [ D.reflow $
839+ "With applications, I try to broaden the constraints to see if anything works,\
840+ \ but messing with package constraints is much more delicate business. E.g. making\
841+ \ your constraints stricter may make it harder for applications to find compatible\
842+ \ dependencies. So fixing something here may break it for a lot of other people!"
843+ , D.reflow $
844+ "So I recommend making an application with the same dependencies as your package.\
845+ \ See if there is a solution at all. From there it may be easier to figure out\
846+ \ how to proceed in a way that will disrupt your users as little as possible. And\
847+ \ the solution may be to help other package authors to get their packages updated,\
848+ \ or to drop a dependency entirely."
849+ ]
850+
851+ InstallNoOfflinePkgSolution pkg ->
852+ Help.report "CANNOT FIND COMPATIBLE VERSION LOCALLY" (Just "elm.json")
853+ (
854+ "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
855+ \ with your existing constraints."
856+ )
857+ [ D.reflow $
858+ "I was not able to connect to https://package.elm-lang.org/ though, so I was only\
859+ \ able to look through packages that you have downloaded in the past."
860+ , D.reflow $
861+ "Try again later when you have internet!"
862+ ]
804
863
805 InstallHadSolverTrouble solver ->
864 InstallHadSolverTrouble solver ->
806 toSolverReport solver
865 toSolverReport solver
@@ -849,26 +908,6 @@ installToReport exit =
849 ]
908 ]
850
909
851
910
852−{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
853− Help.report "OLD DEPENDENCIES" (Just "elm.json")
854− ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
855− )
856− [ D.indent 4 $ D.vcat $ map (D.red . D.fromPackage) badPackages
857− , D.reflow $
858− "This may be because it is not upgraded yet. It may be because a\
859− \ better solution came along, so there was no need to upgrade it.\
860− \ Etc. Try asking around on Slack to learn more about the topic."
861− , D.toSimpleNote
862− "Whatever the case, please be kind to the relevant package authors! Having\
863− \ friendly interactions with users is great motivation, and conversely, getting\
864− \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
865− \ authors are humans with families, friends, jobs, vacations, responsibilities,\
866− \ goals, etc. They face obstacles outside of their technical work you will never\
867− \ know about, so please assume the best and try to be patient and supportive!"
868− ]
869−-}
870−
871−
872
911
873-- SOLVER
912-- SOLVER
874
913
terminal/src/Install.hs+4−4
@@ -196,10 +196,10 @@ makeAppPlan (Solver.Env cache _ connection registry) pkg outline@(Outline.AppOut
196 return (Changes (detectChanges old new) (Outline.App app))
196 return (Changes (detectChanges old new) (Outline.App app))
197
197
198 Solver.NoSolution ->
198 Solver.NoSolution ->
199− Task.throw Exit.InstallNoOnlineSolution
199+ Task.throw (Exit.InstallNoOnlineAppSolution pkg)
200
200
201 Solver.NoOfflineSolution ->
201 Solver.NoOfflineSolution ->
202− Task.throw Exit.InstallNoOfflineSolution
202+ Task.throw (Exit.InstallNoOfflineAppSolution pkg)
203
203
204 Solver.Err exit ->
204 Solver.Err exit ->
205 Task.throw (Exit.InstallHadSolverTrouble exit)
205 Task.throw (Exit.InstallHadSolverTrouble exit)
@@ -252,10 +252,10 @@ makePkgPlan (Solver.Env cache _ connection registry) pkg outline@(Outline.PkgOut
252 }
252 }
253
253
254 Solver.NoSolution ->
254 Solver.NoSolution ->
255− Task.throw Exit.InstallNoOnlineSolution
255+ Task.throw (Exit.InstallNoOnlinePkgSolution pkg)
256
256
257 Solver.NoOfflineSolution ->
257 Solver.NoOfflineSolution ->
258− Task.throw Exit.InstallNoOfflineSolution
258+ Task.throw (Exit.InstallNoOfflinePkgSolution pkg)
259
259
260 Solver.Err exit ->
260 Solver.Err exit ->
261 Task.throw (Exit.InstallHadSolverTrouble exit)
261 Task.throw (Exit.InstallHadSolverTrouble exit)