From d398e590b6de53e291cbccc1988f77ca2bbc9450 Mon Sep 17 00:00:00 2001 From: Leo B <404293+soundmonster@users.noreply.github.com> Date: Wed, 5 Jun 2024 11:28:05 +0200 Subject: [PATCH] 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`. --- lib/next_ls/runtime/bundled_elixir.ex | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/next_ls/runtime/bundled_elixir.ex b/lib/next_ls/runtime/bundled_elixir.ex index cc24e0be..a1bef561 100644 --- a/lib/next_ls/runtime/bundled_elixir.ex +++ b/lib/next_ls/runtime/bundled_elixir.ex @@ -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) @@ -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