Skip to content

Commit fca7d2a

Browse files
authored
Use the cd option in the mix shell (#12410)
This change drops the use of File.cd! when invoking Mix.shell in favor of passing the cd option to the shell invocation. File.cd! is known to have race conditions, unlike the cd option in Mix.shell.
1 parent c4654de commit fca7d2a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,14 @@ defmodule Mix.Tasks.Deps.Compile do
304304
defp do_command(dep, config, command, print_app?, env \\ []) do
305305
%Mix.Dep{app: app, system_env: system_env, opts: opts} = dep
306306

307-
File.cd!(opts[:dest], fn ->
308-
env = [{"ERL_LIBS", Path.join(config[:env_path], "lib")} | system_env] ++ env
307+
env = [{"ERL_LIBS", Path.join(config[:env_path], "lib")} | system_env] ++ env
309308

310-
if Mix.shell().cmd(command, env: env, print_app: print_app?) != 0 do
311-
Mix.raise(
312-
"Could not compile dependency #{inspect(app)}, \"#{command}\" command failed. " <>
313-
deps_compile_feedback(app)
314-
)
315-
end
316-
end)
309+
if Mix.shell().cmd(command, env: env, print_app: print_app?, cd: opts[:dest]) != 0 do
310+
Mix.raise(
311+
"Could not compile dependency #{inspect(app)}, \"#{command}\" command failed. " <>
312+
deps_compile_feedback(app)
313+
)
314+
end
317315

318316
true
319317
end

0 commit comments

Comments
 (0)