diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_utils.erl | 18 | ||||
-rw-r--r-- | src/rebar_fetch.erl | 2 | ||||
-rw-r--r-- | src/rebar_packages.erl | 8 | ||||
-rw-r--r-- | src/rebar_pkg_resource.erl | 4 | ||||
-rw-r--r-- | src/rebar_prv_app_discovery.erl | 4 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 1 |
7 files changed, 31 insertions, 8 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index b14c50a..7239fe7 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -126,6 +126,8 @@ parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_bin not_found -> {PkgName, PkgVsn} = parse_goal(ec_cnv:to_binary(Name) ,ec_cnv:to_binary(Vsn)), + %% Verify package actually exists. This will throw a missing_package exception + rebar_packages:deps(PkgName, PkgVsn, State), Source = {pkg, PkgName, PkgVsn}, rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg) end; @@ -137,6 +139,8 @@ parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Na {ok, _App} -> dep_to_app(root, DepsDir, Name, [], [], IsLock, State); not_found -> + %% Verify package actually exists. This will throw a missing_package exception + rebar_packages:deps(PkgName, PkgVsn, State), Source = {pkg, PkgName, PkgVsn}, rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg) end; @@ -153,6 +157,8 @@ parse_dep(Parent, {_Name, {pkg, Name, Vsn}, Level}, DepsDir, IsLock, State) when {ok, _App} -> dep_to_app(root, DepsDir, Name, [], [], IsLock, State); not_found -> + %% Verify package actually exists. This will throw a missing_package exception + rebar_packages:deps(Name, Vsn, State), Source = {pkg, Name, Vsn}, rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State), pkg) end; @@ -193,6 +199,10 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> end, rebar_app_info:resource_type(rebar_app_info:parent(AppInfo, Parent), ResourceType). +format_error({missing_package, Package}) -> + io_lib:format("Package not found in registry: ~s", [Package]); +format_error({parse_dep, Dep}) -> + io_lib:format("Failed parsing dep ~p", [Dep]); format_error(Error) -> io_lib:format("~p", [Error]). @@ -212,8 +222,12 @@ parse_goal(Name, Constraint) -> end. get_package(Dep, State) -> - {ok, HighestDepVsn} = rebar_packages:find_highest_matching(Dep, "0", ?PACKAGE_TABLE, State), - {Dep, HighestDepVsn}. + case rebar_packages:find_highest_matching(Dep, "0", ?PACKAGE_TABLE, State) of + {ok, HighestDepVsn} -> + {Dep, HighestDepVsn}; + none -> + throw(?PRV_ERROR({missing_package, ec_cnv:to_binary(Dep)})) + end. -spec has_all_beams(file:filename_all(), [module()]) -> true | ?PRV_ERROR({missing_module, module()}). diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 64c5380..b80c125 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -71,6 +71,8 @@ format_error({failed_extract, CachePath}) -> io_lib:format("Failed to extract package: ~s", [CachePath]); format_error({bad_etag, Source}) -> io_lib:format("MD5 Checksum comparison failed for: ~s", [Source]); +format_error({fetch_fail, Name, Vsn}) -> + io_lib:format("Failed to fetch and copy dep: ~s-~s", [Name, Vsn]); format_error({fetch_fail, Source}) -> io_lib:format("Failed to fetch and copy dep: ~p", [Source]); format_error({bad_checksum, File}) -> diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index f6993c5..43df872 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -93,7 +93,7 @@ registry_checksum({pkg, Name, Vsn}, State) -> %% `~> 2.1` | `>= 2.1.0 and < 3.0.0` find_highest_matching(Dep, Constraint, Table, State) -> verify_table(State), - case ets:lookup_element(Table, Dep, 2) of + try ets:lookup_element(Table, Dep, 2) of [[HeadVsn | VsnTail]] -> {ok, handle_vsns(Constraint, HeadVsn, VsnTail)}; [[Vsn]] -> @@ -101,9 +101,9 @@ find_highest_matching(Dep, Constraint, Table, State) -> [Vsn] -> handle_single_vsn(Dep, Vsn, Constraint); [HeadVsn | VsnTail] -> - {ok, handle_vsns(Constraint, HeadVsn, VsnTail)}; - [] -> - ?WARN("Missing registry entry for package ~s. Try to fix with `rebar3 update`", [Dep]), + {ok, handle_vsns(Constraint, HeadVsn, VsnTail)} + catch + error:badarg -> none end. diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl index fdc69e2..3430e81 100644 --- a/src/rebar_pkg_resource.erl +++ b/src/rebar_pkg_resource.erl @@ -34,7 +34,7 @@ download(TmpDir, Pkg={pkg, Name, Vsn}, State) -> Url = string:join([CDN, Package], "/"), cached_download(TmpDir, CachePath, Pkg, Url, etag(CachePath), State). -cached_download(TmpDir, CachePath, Pkg, Url, ETag, State) -> +cached_download(TmpDir, CachePath, Pkg={pkg, Name, Vsn}, Url, ETag, State) -> case request(Url, ETag) of {ok, cached} -> serve_from_cache(TmpDir, CachePath, Pkg, State); @@ -44,7 +44,7 @@ cached_download(TmpDir, CachePath, Pkg, Url, ETag, State) -> ?DEBUG("Download ~s error, using ~s from cache", [Url, CachePath]), serve_from_cache(TmpDir, CachePath, Pkg, State); error -> - request_failed + {fetch_fail, Name, Vsn} end. serve_from_cache(TmpDir, CachePath, Pkg, State) -> diff --git a/src/rebar_prv_app_discovery.erl b/src/rebar_prv_app_discovery.erl index ea55e11..5449f82 100644 --- a/src/rebar_prv_app_discovery.erl +++ b/src/rebar_prv_app_discovery.erl @@ -38,6 +38,10 @@ do(State) -> State1 = rebar_app_discover:do(State, LibDirs), {ok, State1} catch + throw:{error, {rebar_packages, Error}} -> + {error, {rebar_packages, Error}}; + throw:{error, {rebar_app_utils, Error}} -> + {error, {rebar_app_utils, Error}}; throw:{error, Error} -> ?PRV_ERROR(Error) end. diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 0b0f607..49116fc 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -108,6 +108,8 @@ format_error({not_rebar_package, Package, Version}) -> io_lib:format("Package not buildable with rebar3: ~s-~s", [Package, Version]); format_error({missing_package, Package, Version}) -> io_lib:format("Package not found in registry: ~s-~s", [Package, Version]); +format_error({missing_package, Package}) -> + io_lib:format("Package not found in registry: ~s", [Package]); format_error({cycles, Cycles}) -> Prints = [["applications: ", [io_lib:format("~s ", [Dep]) || Dep <- Cycle], diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 4b3a155..fcfb6f7 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -114,6 +114,7 @@ update_deps_list(Deps, HexRegistry, State) -> {ok, HighestDepVsn} -> [{Dep, HighestDepVsn} | DepsListAcc]; none -> + ?WARN("Missing registry entry for package ~s. Try to fix with `rebar3 update`", [Dep]), DepsListAcc end; Vsn -> |