Skip to content

Commit 8fd6c8f

Browse files
wojtekmachjosevalim
authored andcommitted
Ensure Mix.install/2 can be called after errors with deps (#11011)
1 parent 95dcbe9 commit 8fd6c8f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/mix/lib/mix.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,19 @@ defmodule Mix do
576576

577577
:ok = Mix.Local.append_archives()
578578
:ok = Mix.ProjectStack.push(__MODULE__.InstallProject, config, "nofile")
579+
build_dir = Path.join(dir, "_build")
579580

580581
try do
581-
run_deps? = not File.dir?(Path.join(dir, "_build"))
582+
run_deps? = not File.dir?(build_dir)
582583
File.mkdir_p!(dir)
583584

584585
File.cd!(dir, fn ->
585586
if run_deps? do
586587
Mix.Task.rerun("deps.get")
587588
end
588589

589-
Mix.Task.run("compile")
590+
Mix.Task.rerun("deps.loadpaths")
591+
Mix.Task.rerun("compile")
590592
end)
591593

592594
for app <- Mix.Project.deps_apps() do

lib/mix/test/mix_test.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ defmodule MixTest do
8585
end
8686
end
8787

88+
test "install after errors", %{tmp_dir: tmp_dir} do
89+
assert_raise Mix.Error, "Can't continue due to errors on dependencies", fn ->
90+
Mix.install([
91+
{:bad, path: Path.join(tmp_dir, "bad")}
92+
])
93+
end
94+
95+
Mix.install([
96+
{:install_test, path: Path.join(tmp_dir, "install_test")}
97+
])
98+
99+
assert apply(InstallTest, :hello, []) == :world
100+
end
101+
88102
test "consolidate_protocols: false", %{tmp_dir: tmp_dir} do
89103
Mix.install(
90104
[

0 commit comments

Comments
 (0)