@@ -66,7 +66,7 @@ type PackageInstallError
6666 = PackageInstallFailedToFindProjectSourceFiles FileSystem.Error
6767 | PackageInstallFailedToFindSourceFiles { package : PackageName, error : FileSystem.Error }
6868 | PackageInstallInvalidOutline { package : PackageName, message : String }
69- | PackageInstallFailedToLoadBundle Path
69+ | PackageInstallFailedToLoadBundle { package : PackageName, path : Path, message : String }
7070 | PackageInstallInvalidBundle { package : PackageName, path : Path, message : String }
7171 | PackageInstallConflict { package : PackageName, version1 : SemanticVersionRange, version2 : SemanticVersionRange }
7272 | PackageInstallGitError { package : PackageName, error : Git.Error }
@@ -111,9 +111,26 @@ run config { projectPath, outline } =
111111 when constraint is
112112 Outline.Version vsn ->
113113 loadPackageFromBundle config.fsPermission name (SemanticVersionRange.lowerBound vsn) projectPath
114+ |> Task.map Just
115+ |> Task.onError
116+ (\err ->
117+ when err is
118+ PackageInstallFailedToLoadBundle { message } ->
119+ -- Ignore packages that doesn't exist, they
120+ -- will be created in `installStep`
121+ if String.contains "ENOENT" message then
122+ Task.succeed Nothing
123+
124+ else
125+ Task.fail err
126+
127+ _ ->
128+ Task.fail err
129+ )
114130
115131 Outline.LocalPath path ->
116132 loadPackageFromPath config.fsPermission name path
133+ |> Task.map Just
117134 )
118135 |> Task.concurrent
119136 |> Task.map (Array.mapAndKeepJust identity)
@@ -445,23 +462,28 @@ prettifyError error =
445462 ]
446463 )
447464
448- PackageInstallFailedToLoadBundle path ->
465+ PackageInstallFailedToLoadBundle { package, path, message } ->
449466 Help.report
450- "FAILED TO LOAD PACKAGE"
467+ "FAILED TO LOAD PACKAGE BUNDLE "
451468 (Just path)
452469 (PP.verticalBlock
453- [ PP.words "An error occured while I was loading the bundle for this package."
470+ [ PP.words ("An error occured while I was loading the bundle for " ++ PackageName.toString package ++ ".")
471+ , PP.empty
472+ , PP.words "The error is:"
473+ , PP.empty
474+ , PP.words message
475+ |> PP.indent
454476 , PP.empty
455477 , PP.words "Try to delete it and re-run this command to re-generate the bundle."
456478 ]
457479 )
458480
459481 PackageInstallInvalidBundle { package, path, message } ->
460482 Help.report
461- ( "FAILED TO LOAD PACKAGE " ++ PackageName.toString package)
483+ "FAILED TO LOAD PACKAGE BUNDLE"
462484 (Just path)
463485 (PP.verticalBlock
464- [ PP.words "An error occured while I was loading the bundle for this package."
486+ [ PP.words ( "An error occured while I was loading the bundle for " ++ PackageName.toString package ++ ".")
465487 , PP.empty
466488 , PP.words "The error is:"
467489 , PP.empty
@@ -867,7 +889,7 @@ type alias LoadedPackage =
867889
868890
869891-- TODO: extract to module
870- loadPackageFromPath : FileSystem.Permission -> PackageName -> Path -> Task PackageInstallError (Maybe LoadedPackage)
892+ loadPackageFromPath : FileSystem.Permission -> PackageName -> Path -> Task PackageInstallError LoadedPackage
871893loadPackageFromPath fsPermission name path =
872894 let
873895 outlinePath =
@@ -915,18 +937,16 @@ loadPackageFromPath fsPermission name path =
915937
916938 else
917939 Task.succeed
918- (Just
919- { name = name
920- , outline = outline
921- , sources =
922- Array.foldl
923- (\{ moduleName, source } acc ->
924- Dict.set moduleName source acc
925- )
926- Dict.empty
927- sourceFiles
928- }
929- )
940+ { name = name
941+ , outline = outline
942+ , sources =
943+ Array.foldl
944+ (\{ moduleName, source } acc ->
945+ Dict.set moduleName source acc
946+ )
947+ Dict.empty
948+ sourceFiles
949+ }
930950 )
931951
932952 Err jsonErr ->
@@ -936,15 +956,23 @@ loadPackageFromPath fsPermission name path =
936956 }
937957 )
938958
939- loadPackageFromBundle : FileSystem.Permission -> PackageName -> SemanticVersion -> Path -> Task PackageInstallError (Maybe LoadedPackage)
959+
960+ loadPackageFromBundle : FileSystem.Permission -> PackageName -> SemanticVersion -> Path -> Task PackageInstallError LoadedPackage
940961loadPackageFromBundle fsPermission name vsn projectPath =
941962 let
942963 bundlePath =
943964 packageBundlePath name vsn projectPath
944965 in
945966 bundlePath
946967 |> FileSystem.readFileStream fsPermission FileSystem.Beginning
947- |> Task.mapError (\_ -> PackageInstallFailedToLoadBundle bundlePath)
968+ |> Task.mapError
969+ (\fsErr ->
970+ PackageInstallFailedToLoadBundle
971+ { package = name
972+ , path = bundlePath
973+ , message = FileSystem.errorToString fsErr
974+ }
975+ )
948976 |> Task.andThen
949977 (\stream ->
950978 stream
@@ -953,10 +981,10 @@ loadPackageFromBundle fsPermission name vsn projectPath =
953981 |> Task.andThen Stream.Extra.consumeString
954982 |> Task.mapError
955983 (\err ->
956- PackageInstallInvalidBundle
984+ PackageInstallFailedToLoadBundle
957985 { package = name
958986 , path = bundlePath
959- , message = "Failed to read bundle from disk. Error: " ++ Stream.errorToString err
987+ , message = Stream.errorToString err
960988 }
961989 )
962990 |> Task.andThen
@@ -979,12 +1007,10 @@ loadPackageFromBundle fsPermission name vsn projectPath =
9791007
9801008 else
9811009 Task.succeed
982- (Just
983- { name = name
984- , outline = bundle.outline
985- , sources = bundle.sources
986- }
987- )
1010+ { name = name
1011+ , outline = bundle.outline
1012+ , sources = bundle.sources
1013+ }
9881014
9891015 Err jsonErr ->
9901016 Task.fail <| PackageInstallInvalidBundle
0 commit comments