Skip to content

Commit 969d48c

Browse files
author
José Valim
committed
Automatically recompile on outdated elixir version
1 parent f2c9149 commit 969d48c

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Enhancements
44

55
* Bug fixes
6+
* [Mix] Automatically recompile on outdated Elixir version and show proper error messages
67

78
* Deprecations
89
* [Kernel] `%` for sigils is deprecated in favor of `~`

lib/mix/lib/mix/deps.ex

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ defmodule Mix.Deps do
261261
end
262262

263263
def format_status(Mix.Dep[status: { :elixirlock, _ }]),
264-
do: "the dependency is built with an out-of-date elixir version, run `#{mix_env_var}mix deps.get`"
264+
do: "the dependency is built with an out-of-date elixir version, run `#{mix_env_var}mix deps.compile`"
265265

266266
defp dep_status(Mix.Dep[app: app, requirement: req, opts: opts, from: from]) do
267267
info = { app, req, Dict.drop(opts, [:dest, :lock, :env, :build]) }
@@ -311,20 +311,6 @@ defmodule Mix.Deps do
311311
def available?(Mix.Dep[status: { :unavailable, _ }]), do: false
312312
def available?(Mix.Dep[]), do: true
313313

314-
@doc """
315-
Checks if a dependency is out of date, also considering its
316-
lock status. Therefore, be sure to call `check_lock` before
317-
invoking this function.
318-
319-
Out of date dependencies are fixed by simply running `deps.get`.
320-
"""
321-
def out_of_date?(Mix.Dep[status: { :lockmismatch, _ }]), do: true
322-
def out_of_date?(Mix.Dep[status: :lockoutdated]), do: true
323-
def out_of_date?(Mix.Dep[status: :nolock]), do: true
324-
def out_of_date?(Mix.Dep[status: { :elixirlock, _ }]), do: true
325-
def out_of_date?(Mix.Dep[status: { :unavailable, _ }]), do: true
326-
def out_of_date?(Mix.Dep[]), do: false
327-
328314
@doc """
329315
Formats a dependency for printing.
330316
"""

lib/mix/lib/mix/deps/fetcher.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
defmodule Mix.Deps.Fetcher do
88
@moduledoc false
99

10-
import Mix.Deps, only: [format_dep: 1, check_lock: 2, out_of_date?: 1, available?: 1, ok?: 1]
10+
import Mix.Deps, only: [format_dep: 1, check_lock: 2, available?: 1, ok?: 1]
1111

1212
@doc """
1313
Fetches all dependencies.
@@ -57,6 +57,12 @@ defmodule Mix.Deps.Fetcher do
5757
end
5858
end
5959

60+
defp out_of_date?(Mix.Dep[status: { :lockmismatch, _ }]), do: true
61+
defp out_of_date?(Mix.Dep[status: :lockoutdated]), do: true
62+
defp out_of_date?(Mix.Dep[status: :nolock]), do: true
63+
defp out_of_date?(Mix.Dep[status: { :unavailable, _ }]), do: true
64+
defp out_of_date?(Mix.Dep[]), do: false
65+
6066
defp do_finalize({ all_deps, { apps, new_lock } }, old_lock) do
6167
# Let's get the loaded versions of deps
6268
deps = Mix.Deps.loaded_by_name(apps, all_deps)

lib/mix/lib/mix/tasks/deps.check.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ defmodule Mix.Tasks.Deps.Check do
5151
{ Enum.reverse(not_ok), Enum.reverse(compile) }
5252
end
5353

54+
defp compile?(Mix.Dep[status: { :elixirlock, _ }]), do: true
5455
defp compile?(Mix.Dep[status: { :noappfile, _ }]), do: true
5556
defp compile?(Mix.Dep[status: :compile]), do: true
5657
defp compile?(_), do: false

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,11 @@ defmodule Mix.Tasks.DepsTest do
504504
File.write!("_build/dev/lib/ok/.compile.lock", "the_future")
505505
Mix.Task.clear
506506

507-
assert_raise Mix.Error, "Can't continue due to errors on dependencies", fn ->
508-
Mix.Tasks.Deps.Check.run []
509-
end
510-
511-
assert_received { :mix_shell, :error, ["* ok (deps/ok)"] }
512-
assert_received { :mix_shell, :error, [" the dependency is built with an out-of-date elixir version, run `mix deps.get`"] }
507+
Mix.Tasks.Deps.run []
508+
assert_received { :mix_shell, :info, ["* ok (deps/ok)"] }
509+
assert_received { :mix_shell, :info, [" the dependency is built with an out-of-date elixir version, run `mix deps.compile`"] }
513510

514-
Mix.Tasks.Deps.Get.run []
511+
Mix.Tasks.Deps.Check.run []
515512
assert_received { :mix_shell, :info, ["* Compiling ok"] }
516513
end
517514
end

0 commit comments

Comments
 (0)