Skip to content

Mix.install/2: Ensure can be called after errors with deps #11011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/mix/lib/mix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -580,17 +580,19 @@ defmodule Mix do

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

try do
run_deps? = not File.dir?(Path.join(dir, "_build"))
run_deps? = not File.dir?(build_dir)
File.mkdir_p!(dir)

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

Mix.Task.run("compile")
Mix.Task.rerun("deps.loadpaths")
Mix.Task.rerun("compile")
end)

for app <- Mix.Project.deps_apps() do
Expand Down
14 changes: 14 additions & 0 deletions lib/mix/test/mix_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ defmodule MixTest do
end
end

test "install after errors", %{tmp_dir: tmp_dir} do
assert_raise Mix.Error, "Can't continue due to errors on dependencies", fn ->
Mix.install([
{:bad, path: Path.join(tmp_dir, "bad")}
])
end

Mix.install([
{:install_test, path: Path.join(tmp_dir, "install_test")}
])

assert apply(InstallTest, :hello, []) == :world
end

test "consolidate_protocols: false", %{tmp_dir: tmp_dir} do
Mix.install(
[
Expand Down