Skip to content

Commit 9e177fd

Browse files
committed
Ensure load path is enabled on __mix_recompile__?
1 parent 8422af4 commit 9e177fd

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ defmodule Mix.Compilers.Elixir do
4646
{all_modules, all_sources, all_local_exports, old_parents, old_cache_key, old_deps_config} =
4747
parse_manifest(manifest, dest)
4848

49+
# Prepend ourselves early because of __mix_recompile__? checks
50+
# and also that, in case of nothing compiled, we already need
51+
# ourselves available in the path.
52+
Code.prepend_path(dest)
53+
4954
# If modules have been added or removed from the Erlang compiler,
5055
# we need to recompile all references to old and new modules.
5156
stale =
@@ -205,10 +210,6 @@ defmodule Mix.Compilers.Elixir do
205210
Code.purge_compiler_modules()
206211
end
207212
else
208-
# Prepend ourselves, even if we did no work, as we may have defined
209-
# future compilers.
210-
Code.prepend_path(dest)
211-
212213
# We need to return ok if deps_changed? or stale_modules changed,
213214
# even if no code was compiled, because we need to propagate the changed
214215
# status to compile.protocols. This will be the case whenever:

lib/mix/test/mix/tasks/compile.elixir_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,11 @@ defmodule Mix.Tasks.Compile.ElixirTest do
12631263
assert_received {:mix_shell, :info, ["Compiled lib/b.ex"]}
12641264
assert_received {:mix_shell, :info, ["Compiled lib/c.ex"]}
12651265

1266+
# Mix recompile should work even if the compile path
1267+
# was removed and the module purged
1268+
Code.delete_path(Mix.Project.compile_path())
1269+
purge([A])
1270+
12661271
assert Mix.Tasks.Compile.Elixir.run(["--verbose"]) == {:ok, []}
12671272
assert_received {:mix_shell, :info, ["Compiling 1 file (.ex)"]}
12681273
assert_received {:mix_shell, :info, ["Compiled lib/a.ex"]}

0 commit comments

Comments
 (0)