Skip to content

Commit 1c20047

Browse files
committed
fix(runtime): install hex to correct dir
Set `MIX_ARCHIVES` explicitly to make sure to override any existing setting, e.g. from `asdf` or `mise`.
1 parent 78431d1 commit 1c20047

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: lib/next_ls/runtime/bundled_elixir.ex

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ defmodule NextLS.Runtime.BundledElixir do
2424
Path.join(path(base), ".mix")
2525
end
2626

27+
def mix_archives(base) do
28+
Path.join(mix_home(base), "archives")
29+
end
30+
2731
def install(base, logger) do
2832
mixhome = mix_home(base)
33+
mixarchives = mix_archives(base)
2934
File.mkdir_p!(mixhome)
3035
binpath = binpath(base)
3136

@@ -45,12 +50,10 @@ defmodule NextLS.Runtime.BundledElixir do
4550

4651
new_path = "#{binpath}:#{System.get_env("PATH")}"
4752
mixbin = mixpath(base)
53+
env = [{"PATH", new_path}, {"MIX_HOME", mixhome}, {"MIX_ARCHIVES", mixarchives}]
4854

49-
{_, 0} =
50-
System.cmd(mixbin, ["local.rebar", "--force"], env: [{"PATH", new_path}, {"MIX_HOME", mixhome}])
51-
52-
{_, 0} =
53-
System.cmd(mixbin, ["local.hex", "--force"], env: [{"PATH", new_path}, {"MIX_HOME", mixhome}])
55+
{_, 0} = System.cmd(mixbin, ["local.rebar", "--force"], env: env)
56+
{_, 0} = System.cmd(mixbin, ["local.hex", "--force"], env: env)
5457

5558
:ok
5659
rescue

0 commit comments

Comments
 (0)