参考:https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies
https://www.pluralsight.com/guides/installing-elixir-erlang-with-asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.9.0
把下面2行添加到 ~/.bashrc中;
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
然后重新登录bash (或者source ~/.bashrc 也行)
asdf plugin add erlang
asdf plugin add elixir
asdf plugin add nodejs
安装 erlang:
$ asdf list-all erlang
会看到所有可用的erlang版本:
4.7 23.3.4.8 23.3.4.9 23.3.4.10 24.0-rc1 24.0-rc2 24.0-rc3 24.0 24.0.1 24.0.2 24.0.3 24.0.4 24.0.5 24.0.6 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
$ asdf install erlang 24.1.7
asdf_24.1.7 is not a kerl-managed Erlang/OTP installation No build named asdf_24.1.7 Downloading 24.1.7 to /root/.asdf/downloads/erlang/24.1.7... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 654 100 654 0 0 5839 0 --:--:-- --:--:-- --:--:-- 5839 100 102M 100 102M 0 0 12.5M 0 0:00:08 0:00:08 --:--:-- 12.1M Extracting source code Building Erlang/OTP 24.1.7 (asdf_24.1.7), please wait... Erlang 24.1.7 has been installed. Activate globally with: asdf global erlang 24.1.7 Activate locally in the current folder with: asdf local erlang 24.1.7
切换:可以通过 asdf local erlang xx 来切换版本
这里的用法跟 rbenv是一的, global, local ...
通过 .tool-versions 文件来识别不同语言的版本号
安装elixir
# asdf install elixir 1.12.3-otp-24 ==> Checking whether specified Elixir release exists... ==> Downloading 1.12.3-otp-24 to /root/.asdf/downloads/elixir/1.12.3-otp-24/elixir-precompiled-1.12.3-otp-24.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6020k 100 6020k 0 0 133M 0 --:--:-- --:--:-- --:--:-- 133M ==> Copying release into place
安装nodejs:
# asdf install nodejs 16.13.0 Cloning node-build... Downloading node-v16.13.0-linux-x64.tar.gz... -> https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.gz Installing node-v16.13.0-linux-x64... Installed node-v16.13.0-linux-x64 to /root/.asdf/installs/nodejs/16.13.0
在国内使用 遇到的curl raw.github.com 的问题
一般是在安装erlang的时候遇到 , 不要修改 /etc/hosts
需要手动的下载
1. 看一下asdf 使用的版本(见 /home/siwei/.asdf/plugins/erlang/bin/utils.sh)
1 export KERL_VERSION="${ASDF_KERL_VERSION:-2.2.3}"
2 echo "===== ver: $KERL_VERSION"
2. 下载对应的版本到指定位置,例如:
把这个文件手动下载,https://raw.githubusercontent.com/kerl/kerl/2.2.3/kerl
放到这个位置:/home/siwei/.asdf/plugins/erlang/kerl
并且chmod +x 让它可以执行
3. asdf install erlang 就可以了