Skip to content

Commit 78cc8be

Browse files
committed
Fix divergedreq error when update changes requirement and version (#9811)
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.
1 parent 5914aba commit 78cc8be

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/mix/lib/mix/dep.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ defmodule Mix.Dep do
6666
scm: Mix.SCM.t(),
6767
app: atom,
6868
requirement: String.t() | Regex.t() | nil,
69-
status: atom,
69+
status: {:ok, String.t() | nil} | atom | tuple,
7070
opts: keyword,
7171
top_level: boolean,
7272
manager: :rebar | :rebar3 | :mix | :make | nil,

lib/mix/lib/mix/dep/fetcher.ex

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ defmodule Mix.Dep.Fetcher do
6565
end
6666

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

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

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

0 commit comments

Comments
 (0)