Skip to content

Commit 806a889

Browse files
committed
Change rebar compile command to use System.cmd rather than Mix.shell().cmd(), in order to avoid escaping errors.
1 parent 99be673 commit 806a889

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ defmodule Mix.Tasks.Deps.Compile do
207207
{"TERM", "dumb"}
208208
]
209209

210-
cmd = "#{rebar_cmd(dep)} bare compile --paths #{escape_path(lib_path)}"
211-
do_command(dep, config, cmd, false, env)
210+
cmd = rebar_cmd(dep)
211+
args = ["bare", "compile", "--paths", lib_path]
212+
do_command(dep, config, cmd, args, env)
212213

213214
# Check if we have any new symlinks after compilation
214215
for dir <- ~w(include priv src),
@@ -220,11 +221,6 @@ defmodule Mix.Tasks.Deps.Compile do
220221
true
221222
end
222223

223-
defp escape_path(path) do
224-
escape = if match?({:win32, _}, :os.type()), do: "^ ", else: "\\ "
225-
String.replace(path, " ", escape)
226-
end
227-
228224
defp rebar_config(dep) do
229225
dep.extra
230226
|> Mix.Rebar.dependency_config()
@@ -260,7 +256,7 @@ defmodule Mix.Tasks.Deps.Compile do
260256

261257
defp do_make(dep, config) do
262258
command = make_command(dep)
263-
do_command(dep, config, command, true, [{"IS_DEP", "1"}])
259+
do_shell_command(dep, config, command, true, [{"IS_DEP", "1"}])
264260
build_structure(dep, config)
265261
true
266262
end
@@ -289,15 +285,30 @@ defmodule Mix.Tasks.Deps.Compile do
289285

290286
defp do_compile(%Mix.Dep{opts: opts} = dep, config) do
291287
if command = opts[:compile] do
292-
do_command(dep, config, command, true)
288+
do_shell_command(dep, config, command, true)
293289
build_structure(dep, config)
294290
true
295291
else
296292
false
297293
end
298294
end
299295

300-
defp do_command(dep, config, command, print_app?, env \\ []) do
296+
defp do_command(dep, config, command, args, env \\ []) do
297+
%Mix.Dep{app: app, system_env: system_env, opts: opts} = dep
298+
299+
env = [{"ERL_LIBS", Path.join(config[:deps_build_path], "lib")} | system_env] ++ env
300+
301+
if elem(System.cmd(command, args, env: env, cd: opts[:dest]), 1) != 0 do
302+
Mix.raise(
303+
"Could not compile dependency #{inspect(app)}, \"#{command}\" command failed. " <>
304+
deps_compile_feedback(app)
305+
)
306+
end
307+
308+
true
309+
end
310+
311+
defp do_shell_command(dep, config, command, print_app?, env \\ []) do
301312
%Mix.Dep{app: app, system_env: system_env, opts: opts} = dep
302313

303314
env = [{"ERL_LIBS", Path.join(config[:deps_build_path], "lib")} | system_env] ++ env

0 commit comments

Comments
 (0)