From 50b9b456f7a3ea188fd3916822acdacc894f2e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Tue, 21 Jun 2016 23:13:29 +0200 Subject: [PATCH] Do not load mix.exs file for rebar deps --- lib/mix/lib/mix/dep/loader.ex | 30 +++++++++++++-------------- lib/mix/lib/mix/tasks/deps.compile.ex | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/mix/lib/mix/dep/loader.ex b/lib/mix/lib/mix/dep/loader.ex index d1d09cabee4..72ea016df8c 100644 --- a/lib/mix/lib/mix/dep/loader.ex +++ b/lib/mix/lib/mix/dep/loader.ex @@ -266,22 +266,22 @@ defmodule Mix.Dep.Loader do {dep, deps} end - defp rebar_dep(%Mix.Dep{app: app} = dep, children, manager) do - Mix.Dep.in_dependency(dep, fn _ -> - config = Mix.Rebar.load_config(".") - extra = Mix.Rebar.merge_config(dep.extra, config) - deps = - if children do - from = Path.absname("rebar.config") - # Pass the manager because deps of a Rebar project need - # to default to Rebar if we cannot chose a manager from - # files in the dependency - Enum.map(children, &to_dep(&1, from, manager)) - else - rebar_children(app, config, extra, manager) - end - {%{dep | extra: extra}, deps} + defp rebar_dep(%Mix.Dep{app: app, opts: opts} = dep, children, manager) do + config = File.cd!(opts[:dest], fn -> + Mix.Rebar.load_config(".") end) + extra = Mix.Rebar.merge_config(dep.extra, config) + deps = + if children do + from = Path.absname("rebar.config") + # Pass the manager because deps of a Rebar project need + # to default to Rebar if we cannot chose a manager from + # files in the dependency + Enum.map(children, &to_dep(&1, from, manager)) + else + rebar_children(app, config, extra, manager) + end + {%{dep | extra: extra}, deps} end defp make_dep(dep) do diff --git a/lib/mix/lib/mix/tasks/deps.compile.ex b/lib/mix/lib/mix/tasks/deps.compile.ex index c32c8f380a0..feb8e12e7a1 100644 --- a/lib/mix/lib/mix/tasks/deps.compile.ex +++ b/lib/mix/lib/mix/tasks/deps.compile.ex @@ -202,15 +202,15 @@ defmodule Mix.Tasks.Deps.Compile do end end - defp do_command(%Mix.Dep{app: app} = dep, config, command, print_app?, env \\ []) do - Mix.Dep.in_dependency dep, fn _ -> + defp do_command(%Mix.Dep{app: app, opts: opts}, config, command, print_app?, env \\ []) do + File.cd!(opts[:dest], fn -> env = [{"ERL_LIBS", Path.join(config[:env_path], "lib")}] ++ env if Mix.shell.cmd(command, print_app: print_app?, env: env) != 0 do Mix.raise "Could not compile dependency #{inspect app}, \"#{command}\" command failed. " <> "You can recompile this dependency with \"mix deps.compile #{app}\", update it " <> "with \"mix deps.update #{app}\" or clean it with \"mix deps.clean #{app}\"" end - end + end) true end