anchor.diff:      find_highest_matching(undefined, undefined, Dep, Constraint, Table, State).
   
   find_highest_matching(Pkg, PkgVsn, Dep, Constraint, Table, State) ->
  +    try find_highest_matching_(Pkg, PkgVsn, Dep, Constraint, Table, State) of
  +        none ->
  +            handle_missing_package(Dep, State,
  +                                   fun(State1) ->
  +                                       find_highest_matching_(Pkg, PkgVsn, Dep, Constraint, Table, State1)
  +                                   end);
  +        Result ->
  +            Result
  +    catch
  +        _:_ ->
  +            handle_missing_package(Dep, State,
  +                                   fun(State1) ->
  +                                       find_highest_matching_(Pkg, PkgVsn, Dep, Constraint, Table, State1)
  +                                   end)
  +    end.
  +
  +find_highest_matching_(Pkg, PkgVsn, Dep, Constraint, Table, State) ->
       try find_all(Dep, Table, State) of
           {ok, [Vsn]} ->
               handle_single_vsn(Pkg, PkgVsn, Dep, Vsn, Constraint);
  
positive.code:         deps_(Name, Vsn, State)
      catch
          _:_ ->
              handle_missing_package(Name, Vsn, State)
      end.
  
  deps_(Name, Vsn, State) ->
      ?MODULE:verify_table(State),
      ets:lookup_element(?PACKAGE_TABLE, {ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)}, 2).
  
  handle_missing_package(Name, Vsn, State) ->
      ?INFO("Package ~s-~s not found. Fetching registry updates and trying again...", [Name, Vsn]),
      {ok, State1} = rebar_prv_update:do(State),
      try
          deps_(Name, Vsn, State1)
      catch
          _:_ ->
              %% Even after an update the package is still missing, time to error out
              throw(?PRV_ERROR({missing_package, ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)}))
      end.
  
  registry_dir(State) ->
  
negative.code:             {ok, Vsn}
      end.
  
  format_error({missing_package, {Name, Vsn}}) ->
      io_lib:format("Package not found in registry: ~s-~s.", [ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)]);
  format_error({missing_package, Dep}) ->
      io_lib:format("Package not found in registry: ~p.", [Dep]).
  
  verify_table(State) ->
      ets:info(?PACKAGE_TABLE, named_table) =:= true orelse load_and_verify_version(State).
  