Linux Mint 20.3 に ASDF で Elixir をインストールする

簡単に apt で入れようと思ったのですが、なぜかうまくいかなかったので、せっかくなので ASDF を使って入れてみました。ASDFバージョン管理システムで、複数のバージョンを管理できます。
asdf-vm.com
 
ここを参考にしました。
www.pluralsight.com
 

作業

Elixir には Erlang が必要なので、これもインストールします。

まずは curl と git をいれます。

sudo apt update
sudo apt install curl git

まあ、既に入っている人が多いですよね。

ASDF をクローンします。

git clone https://github.com/asdf-vm/asdf.git ~/.asdf

 
端末を設定します。僕が使っているのは Bash なので、~/.bashrcの最後の行に以下を追加します。

. $HOME/.asdf/asdf.sh

端末を再起動します。

プラグインをインストールします。

asdf plugin add erlang
asdf plugin add elixir

 
インストールできる Erlang のバージョンを調べます。

asdf list-all erlang

こんな風に出ます。

(...)
24.1
24.1.1
24.1.2
24.1.3
24.1.4
24.1.5
24.1.6
24.1.7
24.2
24.2.1
24.2.2
24.3
25.0-rc1

安定版の最新は24.3のようなので、これをインストールしてみます。

asdf install erlang 24.3

こんな風に表示されました。(いろいろ出てくるので、備忘録として記録しておきます。)

asdf_24.3 is not a kerl-managed Erlang/OTP installation
No build named asdf_24.3
Downloading 24.3 to /home/tomoki/.asdf/downloads/erlang/24.3...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   652  100   652    0     0   8467      0 --:--:-- --:--:-- --:--:--  8467
100  102M  100  102M    0     0  4221k      0  0:00:24  0:00:24 --:--:-- 6066k
Extracting source code
Building Erlang/OTP 24.3 (asdf_24.3), please wait...
WARNING: It appears that a required development package 'libssl-dev' is not installed.
APPLICATIONS DISABLED (See: /home/tomoki/.asdf/plugins/erlang/kerl-home/builds/asdf_24.3/otp_build_24.3.log)
 * jinterface     : No Java compiler found
 * odbc           : ODBC library - link check failed

APPLICATIONS INFORMATION (See: /home/tomoki/.asdf/plugins/erlang/kerl-home/builds/asdf_24.3/otp_build_24.3.log)
 * wx             : wxWidgets was not compiled with --enable-webview or wxWebView developer package is not installed, wxWebView will NOT be available
 *         wxWidgets must be installed on your system.
 *         Please check that wx-config is in path, the directory
 *         where wxWidgets libraries are installed (returned by
 *         'wx-config --libs' or 'wx-config --static --libs' command)
 *         is in LD_LIBRARY_PATH or equivalent variable and
 *         wxWidgets version is 3.0.2 or above.

DOCUMENTATION INFORMATION (See: /home/tomoki/.asdf/plugins/erlang/kerl-home/builds/asdf_24.3/otp_build_24.3.log)
 * documentation  : 
 *                  xsltproc is missing.
 *                  fop is missing.
 *                  The documentation cannot be built.

Erlang/OTP 24.3 (asdf_24.3) has been successfully built
Installing Erlang/OTP 24.3 (asdf_24.3) in /home/tomoki/.asdf/installs/erlang/24.3...
You can activate this installation running the following command:
. /home/tomoki/.asdf/installs/erlang/24.3/activate
Later on, you can leave the installation typing:
kerl_deactivate
Cleaning up compilation products for 
Cleaned up compilation products for  under /home/tomoki/.asdf/plugins/erlang/kerl-home/builds

いろいろ警告など出ていますが、いちおう Erlang をインストールできたようです。

次は Elixir です。
同じようにインストールできるバージョンを調べます。

asdf list-all elixir

こんな風に出ます。

(...)
1.13.2
1.13.2-otp-22
1.13.2-otp-23
1.13.2-otp-24
1.13.3
1.13.3-otp-22
1.13.3-otp-23
1.13.3-otp-24
main
main-otp-22
main-otp-23
main-otp-24
master
master-otp-21
master-otp-22
master-otp-23
master-otp-24

otp が付いたバージョンの方がよいらしいので、その最新安定版と思われる1.13.3-otp-24をインストールします。この24は、インストールした Erlang のバージョンだと思います。

asdf install elixir 1.13.3-otp-24

これで Elixir がインストールされた筈です。

全体で使うバージョンを指定します。

asdf global erlang 24.3
asdf global elixir 1.13.3-otp-24

globalのところをlocalに替えれば、そのパスでのみ使われるバージョンが指定できます。
 
本当にインストールできたのか、試してみます。iexで Elixir の REPL を立ち上げてみます。

Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

Interactive Elixir (1.13.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> IO.puts "Hello, World!"
Hello, World!
:ok
iex(2)> 

無事インストールされていました。