Skip to content

Commit b6b70a2

Browse files
committed
Always append paths and archives when Mix app starts
1 parent 5fcefe4 commit b6b70a2

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/mix/lib/mix.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,22 @@ defmodule Mix do
387387
:ok
388388
end
389389

390-
@doc false
390+
@impl true
391391
def start(_type, []) do
392+
Mix.Local.append_archives()
393+
Mix.Local.append_paths()
392394
children = [Mix.State, Mix.TasksServer, Mix.ProjectStack]
393395
opts = [strategy: :one_for_one, name: Mix.Supervisor, max_restarts: 0]
394396
Supervisor.start_link(children, opts)
395397
end
396398

399+
@impl true
400+
def stop(_data) do
401+
Mix.Local.remove_archives()
402+
Mix.Local.remove_paths()
403+
:ok
404+
end
405+
397406
@doc """
398407
Returns the current Mix environment.
399408
@@ -827,7 +836,6 @@ defmodule Mix do
827836
]
828837

829838
started_apps = Application.started_applications()
830-
:ok = Mix.Local.append_archives()
831839
:ok = Mix.ProjectStack.push(@mix_install_project, config, "nofile")
832840
build_dir = Path.join(install_dir, "_build")
833841
external_lockfile = expand_path(opts[:lockfile], deps, :lockfile, "mix.lock")

lib/mix/lib/mix/cli.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ defmodule Mix.CLI do
55
Runs Mix according to the command line arguments.
66
"""
77
def main(args \\ System.argv()) do
8-
Mix.Local.append_archives()
9-
Mix.Local.append_paths()
108
Mix.start()
119

1210
if env_variable_activated?("MIX_QUIET"), do: Mix.shell(Mix.Shell.Quiet)

lib/mix/lib/mix/local.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ defmodule Mix.Local do
7878
Enum.each(mix_paths(), &Code.append_path/1)
7979
end
8080

81+
@doc """
82+
Removes Mix paths from the Erlang code path.
83+
"""
84+
def remove_paths do
85+
Enum.each(mix_paths(), &Code.delete_path/1)
86+
end
87+
8188
defp mix_paths do
8289
if path = System.get_env("MIX_PATH") do
8390
String.split(path, path_separator())

0 commit comments

Comments
 (0)