Skip to content

Commit 2252a8f

Browse files
committed
Fix erts handling when loading apps
1 parent 9a9cf41 commit 2252a8f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

lib/mix/lib/mix/app_loader.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ defmodule Mix.AppLoader do
9797

9898
defp extra_apps(config) do
9999
case Keyword.get(config, :language, :elixir) do
100-
:elixir -> [:ex_unit, :iex, :mix, :elixir, :erts]
101-
:erlang -> [:compiler, :erts]
100+
:elixir -> [:ex_unit, :iex, :mix, :elixir]
101+
:erlang -> [:compiler]
102102
end
103103
end
104104

@@ -136,8 +136,12 @@ defmodule Mix.AppLoader do
136136
end
137137

138138
# We have processed all apps.
139-
defp traverse_apps([], _seen, _deps_children, _builtin_paths, _lib_path) do
140-
[]
139+
defp traverse_apps([], seen, _deps_children, builtin_paths, _lib_path) do
140+
# We want to keep erts in the load path but it doesn't require to be loaded.
141+
case builtin_paths do
142+
%{erts: path} when not is_map_key(seen, :erts) -> [{:erts, path}]
143+
%{} -> []
144+
end
141145
end
142146

143147
defp app_children(app) do

lib/mix/lib/mix/tasks/compile.all.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule Mix.Tasks.Compile.All do
3131
{loaded_paths, loaded_modules} =
3232
Mix.AppLoader.load_apps(apps, deps, config, {[], []}, fn {app, path}, {paths, mods} ->
3333
paths = if path, do: [path | paths], else: paths
34-
mods = if app_cache, do: [{app, Application.spec(app, :modules)} | mods], else: mods
34+
mods = if app_cache, do: [{app, Application.spec(app, :modules) || []} | mods], else: mods
3535
{paths, mods}
3636
end)
3737

lib/mix/test/mix/tasks/compile_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ defmodule Mix.Tasks.CompileTest do
336336
assert Mix.Task.run("compile", []) == {:ok, []}
337337
assert :code.where_is_file(~c"parsetools.app") == :non_existing
338338

339-
# Make sure erts is also kept
339+
# Make sure erts is also kept but not loaded
340340
assert {:docs_v1, _, _, _, _, _, _} = Code.fetch_docs(:zlib)
341+
assert Application.spec(:erts, :vsn) == nil
341342
end)
342343
end
343344

0 commit comments

Comments
 (0)