Skip to content

Commit

Permalink
fix(runtime): install hex to correct dir
Browse files Browse the repository at this point in the history
Set `MIX_ARCHIVES` explicitly to make sure to override any existing
setting, e.g. from `asdf` or `mise`.
  • Loading branch information
soundmonster committed Jun 11, 2024
1 parent 1a94fb7 commit d398e59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/next_ls/runtime/bundled_elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ defmodule NextLS.Runtime.BundledElixir do
Path.join(path(base), ".mix")
end

def mix_archives(base) do
Path.join(mix_home(base), "archives")
end

def install(base, logger) do
mixhome = mix_home(base)
mixarchives = mix_archives(base)
File.mkdir_p!(mixhome)
binpath = binpath(base)

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

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

{_, 0} =
System.cmd(mixbin, ["local.rebar", "--force"], env: [{"PATH", new_path}, {"MIX_HOME", mixhome}])

{_, 0} =
System.cmd(mixbin, ["local.hex", "--force"], env: [{"PATH", new_path}, {"MIX_HOME", mixhome}])
{_, 0} = System.cmd(mixbin, ["local.rebar", "--force"], env: env)
{_, 0} = System.cmd(mixbin, ["local.hex", "--force"], env: env)

:ok
rescue
Expand Down

0 comments on commit d398e59

Please sign in to comment.