Skip to content

Commit

Permalink
Fix divergedreq error when update changes requirement and version (#9811
Browse files Browse the repository at this point in the history
)

The fix is to mark the dependency for compilation in the Fetcher (by
touching .fetch) so that the Loader wont read the version from the .app
file.
  • Loading branch information
ericmj committed Feb 13, 2020
1 parent 4cfad26 commit 30c5f49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/dep.ex
Expand Up @@ -66,7 +66,7 @@ defmodule Mix.Dep do
scm: Mix.SCM.t(),
app: atom,
requirement: String.t() | Regex.t() | nil,
status: atom,
status: {:ok, String.t() | nil} | atom | tuple,
opts: keyword,
top_level: boolean,
manager: :rebar | :rebar3 | :mix | :make | nil,
Expand Down
11 changes: 4 additions & 7 deletions lib/mix/lib/mix/dep/fetcher.ex
Expand Up @@ -65,6 +65,7 @@ defmodule Mix.Dep.Fetcher do
end

if new do
File.touch!(Path.join(opts[:dest], ".fetch"))
dep = put_in(dep.opts[:lock], new)
{dep, [app | acc], Map.put(lock, app, new)}
else
Expand Down Expand Up @@ -92,22 +93,18 @@ defmodule Mix.Dep.Fetcher do
# dependency is missing, it could directly affect one of the
# dependencies we are trying to compile, causing the whole thing
# to fail.
#
# If there is any other dependency that is not ok, we include
# it for compilation too, this is our best to try to solve the
# maximum we can at each deps.get and deps.update.
deps =
parent_deps =
if Enum.all?(all_deps, &available?/1) do
Enum.uniq_by(with_depending(deps, all_deps), & &1.app)
else
deps
[]
end

# Merge the new lock on top of the old to guarantee we don't
# leave out things that could not be fetched and save it.
lock = Map.merge(old_lock, new_lock)
Mix.Dep.Lock.write(lock)
mark_as_fetched(deps)
mark_as_fetched(parent_deps)

# See if any of the deps diverged and abort.
show_diverged!(Enum.filter(all_deps, &Mix.Dep.diverged?/1))
Expand Down

0 comments on commit 30c5f49

Please sign in to comment.