Intellij-elixir: Select SDK on Linux with Elixir managed by asdf manager

Created on 16 May 2016  路  14Comments  路  Source: KronicDeth/intellij-elixir

Hi!

I'm using Elixir installed with asdf version manager and I believe this is the only reason why your plug-in can't find Elixir SDK.

asdf is using the next directories structure:

/home//.asdf/shims - wrappers (shell command files) to the actual executables (for ex., mix, elixir and elixirc).
/home//.asdf/installs/elixir// - the actual Elixir root path, where is like 1.2.3 (for ex., /home/vlad/.asdf/installs/elixir/1.2.3/ - path to the currently latest Elixir SDK in my system). Obviously there can be a number of different Exlir versions.

Thanks a lot for the great product!

Enhancement

Most helpful comment

Also, it would be great if the plugin would read .tool-versions (file created by asdf) and setup elixir automatically.

All 14 comments

So what is your issue about? Are you saying plugin should support ASDF-managed elixir installations?

@develop7, thanks for the question.

There is an ask in the plugin initializer to send environment info if this plugin can't find Elixir paths by itself. So I did.

As there is no syntax highlighting at the moment (or I haven't found the way to enable it after a brief look) I went back to the sublime with ElixirSublime and can't make a PR to add asdf support.

When selecting the directory, intellij cannot find elixir and just shows the following messages:

Probably SDK installed in '/home/user/.asdf/installs/elixir/1.3.2' is corrupt
Unknown Elixir version at /home/user/.asdf/installs/elixir/1.3.2

Also, it would be great if the plugin would read .tool-versions (file created by asdf) and setup elixir automatically.

A workaround that works for me:

cd ~/bin
ln -s ~/.asdf/shims/elixir
ln -s ~/.asdf/shims/erl
ln -s ~/.asdf/shims/mix
ln -s ~/.asdf/shims/iex

After this I remove and add again the asdf elixir sdk and it is found correctly.

Update:

As per project the plugin should select the Elixir SDK folder this issue does'nt happen right now,
but i'm trying to executing the debug and he gets the system Erlang witch is different from asdf,
so I needed to set again ln -s ~/.asdf/shims/erl to work properly.

As a point of interest, I was able to get the SDK set up in OS/X with asdf installed via brew install asdf by adding the directories /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3 and /usr/local/Cellar/asdf/0.4.0/installs/erlang/20.1 to the global SDKs. I'm still running into the hex issue described in #823 though.

My IntelliJ plugin-fu is probably not good enough to come up with a PR for this, but I can at least describe the steps needed to find an asdf Elixir install:

  • Read ~/.tool-versions to get the current asdf global elixir settings:
% cat ~/.tool-versions
erlang 20.1
elixir 1.5.3
  • If this file exists, we can reasonably expect asdf to be installed. Find the install roots via:
% asdf where erlang 20.1
/usr/local/opt/asdf/installs/erlang/20.1

% asdf where elixir 1.5.3
/usr/local/opt/asdf/installs/elixir/1.5.3

% $(asdf where elixir 1.5.3)/bin/mix hex
Hex v0.17.1
Hex is a package manager for the Erlang ecosystem.
[...]
  • Per my notes on #823, if it exists, we can infer the values of the env vars MIX_ARCHIVES and MIX_HOME the same way the asdf elixir plugin does, using the values from asdf where as $ASDF_INSTALL_PATH:

https://github.com/asdf-vm/asdf-elixir/blob/master/bin/exec-env

@timgilbert How does one add those paths to "the global SDKs"? Is it https://www.jetbrains.com/help/idea/working-with-sdks.html#manage_sdks?

@wizonesolutions: yeah, I set them in the global SDK settings. It's not super obvious where they live but you can get to them like this:

  • From "File / Project Structure / Platform Settings -> SDKs", hit the + sign and select "Erlang SDK for Elixir SDK"
  • Command-Shift-G to go to /usr/local/opt/asdf, click into installs/erlang/20.2 and hit Open.
  • Use + again to add the Elixir SDK under installs/elixir/1.5.2
  • Now in the same dialog box go to the "Project Settings / Project" page, and you should have "Elixir 1.5.2" available in the "Project SDK" dropdown.

Hope this helps!

Is "Erlang SDK for Elixir SDK" different than Erlang SDK? It didn't seem like Elixir actually cared. The main thing that helped was the symlinking to /usr/local/bin, as it does not seem to actually use the Erlang SDK path when it tries to find Erlang? Anyone, thanks for your tips!

"Erlang SDK for Elixir SDK" is the one supplied by this intellij-elixir plugin. "Erlang SDK" is the one supplied by the intellij-erlang plugin. I had to make the "Erlang SDK for Elixir SDK" for people that don't install the intellij-erlang plugin.

I was facing the same problem, but after setting elixir & erlang version as global it stopped to happen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

merqlove picture merqlove  路  3Comments

KronicDeth picture KronicDeth  路  3Comments

ryancammer picture ryancammer  路  5Comments

SyedWasiHaider picture SyedWasiHaider  路  4Comments

joshuataylor picture joshuataylor  路  3Comments