Skip to content

Commit 2520243

Browse files
authored
Restore Hex code paths after compilation pruning (#1118)
Compilation prunes code paths for isolation, which may remove archive paths like Hex. When a task like `format` triggers compilation and then `deps.get` runs in the same VM, Hex.Mix becomes unavailable. Call Mix.ensure_application!(:hex) to restore the code paths before converging dependencies. Closes #1109
1 parent 84f2d67 commit 2520243

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/hex/remote_converger.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ defmodule Hex.RemoteConverger do
2525
end
2626

2727
def converge(deps, lock) do
28+
unless Code.ensure_loaded?(Hex.Mix) do
29+
Hex.Stdlib.ensure_application!(:hex)
30+
end
31+
2832
Registry.open()
2933

3034
# Check and refresh OAuth token before fetching packages

lib/hex/stdlib.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ defmodule Hex.Stdlib do
1616
apply(:public_key, :ssh_hostkey_fingerprint, [digset_type, key])
1717
end
1818
end
19+
20+
# Compilation prunes code paths for isolation, which may remove archive
21+
# paths like Hex. Restore them so all Hex modules are available.
22+
def ensure_application!(app) do
23+
if function_exported?(Mix, :ensure_application!, 1) do
24+
apply(Mix, :ensure_application!, [app])
25+
end
26+
end
1927
end

0 commit comments

Comments
 (0)