Kaynağa Gözat

Merge pull request #742 from tsloughter/pkg_check

improve error messages for packages by checking its existance before fetch
pull/745/head
Tristan Sloughter 9 yıl önce
ebeveyn
işleme
657a1bf52e
6 değiştirilmiş dosya ile 29 ekleme ve 6 silme
  1. +16
    -2
      src/rebar_app_utils.erl
  2. +2
    -0
      src/rebar_fetch.erl
  3. +4
    -4
      src/rebar_packages.erl
  4. +4
    -0
      src/rebar_prv_app_discovery.erl
  5. +2
    -0
      src/rebar_prv_install_deps.erl
  6. +1
    -0
      src/rebar_prv_update.erl

+ 16
- 2
src/rebar_app_utils.erl Dosyayı Görüntüle

@ -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()}).

+ 2
- 0
src/rebar_fetch.erl Dosyayı Görüntüle

@ -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}) ->

+ 4
- 4
src/rebar_packages.erl Dosyayı Görüntüle

@ -106,7 +106,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]] ->
@ -114,9 +114,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.

+ 4
- 0
src/rebar_prv_app_discovery.erl Dosyayı Görüntüle

@ -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.

+ 2
- 0
src/rebar_prv_install_deps.erl Dosyayı Görüntüle

@ -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],

+ 1
- 0
src/rebar_prv_update.erl Dosyayı Görüntüle

@ -117,6 +117,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 ->

Yükleniyor…
İptal
Kaydet