JakeBecker/ide-elixir

Support use with version managers like asdf (start elixir-ls in the project directory)

ejpcmac opened this issue · 1 comments

Problem description

I use asdf for my Elixir projects. That permits me to set a global Elixir and Erlang version and a local version per project, thanks to a .tool-versions file.

In the terminal, the correct version is automatically inferred and used. However, this is not the case with elixir-ls launched from Atom, even if I launch Atom from the terminal using atom .. I end up with my project completely re-compiled twice when I save a file:

  • once by elixir-ls, using the global Elixir version
  • once by mix test.watch running in the console, using the local Elixir version

This is not usable as-is and I need to change the global Elixir version to fit the project one to get all work properly.

Ideas

When launching Atom from an asdf-enable terminal session, it should work, because $PATH contains the asdf shims for Elixir and Erlang. I think the problem must come from the directory where elixir-ls is executed. It should be the project’s root directory.

Reading the code, I think it can be resolved by adding a cwd option to this line:

startServerProcess(projectPath) {
  const command = os.platform() == "win32" ? "mix.bat" : "mix";
  const elixirLsPath = path.resolve(__dirname, "../elixir-ls-release");
  const env = Object.assign({}, process.env, { ERL_LIBS: elixirLsPath });
  return cp.spawn(command, ["elixir_ls.language_server"], { env: env, cwd: projectPath });
}

I’ll try this this week-end.