From b9c330d46e25c4bd6a2eeb4b3b78cd6fcd34d694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Wed, 2 Mar 2016 04:22:55 +0100 Subject: [PATCH] Explicitly open registry and clean pdict --- lib/hex/mix.ex | 3 +++ lib/hex/remote_converger.ex | 7 +++++++ lib/hex/scm.ex | 8 ++++++++ lib/mix/tasks/hex/outdated.ex | 3 +++ 4 files changed, 21 insertions(+) diff --git a/lib/hex/mix.ex b/lib/hex/mix.ex index b3582e1b8..e47746b99 100644 --- a/lib/hex/mix.ex +++ b/lib/hex/mix.ex @@ -122,6 +122,9 @@ defmodule Hex.Mix do else: requests end + @doc """ + Prepare Mix dependencies for the format the resolver expects. + """ @spec prepare_deps([Mix.Dep.t]) :: [dep] def prepare_deps(deps) do Enum.map(deps, fn %Mix.Dep{app: app, deps: deps, opts: opts} -> diff --git a/lib/hex/remote_converger.ex b/lib/hex/remote_converger.ex index 58f10189d..f12be9f35 100644 --- a/lib/hex/remote_converger.ex +++ b/lib/hex/remote_converger.ex @@ -12,6 +12,7 @@ defmodule Hex.RemoteConverger do def converge(deps, lock) do Hex.start Hex.Utils.ensure_registry!() + Hex.Registry.open!(Hex.Registry.ETS) verify_lock(lock) # We cannot use given lock here, because all deps that are being @@ -43,9 +44,13 @@ defmodule Hex.RemoteConverger do Hex.Shell.error message Mix.raise "Hex dependency resolution failed, relax the version requirements or unlock dependencies" end + after + Hex.Registry.pdict_clean end def deps(%Mix.Dep{app: app}, lock) do + Hex.Registry.open!(Hex.Registry.ETS) + case Map.fetch(lock, app) do {:ok, {:hex, name, version}} -> deps = get_deps(name, version) @@ -53,6 +58,8 @@ defmodule Hex.RemoteConverger do _ -> [] end + after + Hex.Registry.pdict_clean end defp get_deps(name, version) do diff --git a/lib/hex/scm.ex b/lib/hex/scm.ex index 476ffc03f..315f3b474 100644 --- a/lib/hex/scm.ex +++ b/lib/hex/scm.ex @@ -59,6 +59,8 @@ defmodule Hex.SCM do end def managers(opts) do + Hex.Registry.open!(Hex.Registry.ETS) + case opts[:lock] do {:hex, name, version} -> name = Atom.to_string(name) @@ -67,9 +69,13 @@ defmodule Hex.SCM do _ -> [] end + after + Hex.Registry.pdict_clean end def checkout(opts) do + Hex.Registry.open!(Hex.Registry.ETS) + {:hex, _name, version} = opts[:lock] name = opts[:hex] dest = opts[:dest] @@ -100,6 +106,8 @@ defmodule Hex.SCM do File.write!(Path.join(dest, ".hex"), manifest) opts[:lock] + after + Hex.Registry.pdict_clean end def update(opts) do diff --git a/lib/mix/tasks/hex/outdated.ex b/lib/mix/tasks/hex/outdated.ex index 4684a55d7..1f577bbab 100644 --- a/lib/mix/tasks/hex/outdated.ex +++ b/lib/mix/tasks/hex/outdated.ex @@ -34,6 +34,9 @@ defmodule Mix.Tasks.Hex.Outdated do lock = Mix.Dep.Lock.read deps = Mix.Dep.loaded([]) |> Enum.filter(& &1.scm == Hex.SCM) + # Re-open registry because loading deps cleans the process dict + Hex.Utils.ensure_registry!() + case args do [app] -> single(deps, lock, app, opts)