DEV Community

Cover image for Installing Erlang & Elixir using asdf on M1 Macs
Oliver Andrich
Oliver Andrich

Posted on

Installing Erlang & Elixir using asdf on M1 Macs

This weekend I discovered, that somehow Elixir-LS in VSCode and Sublime Text stopped to support autocompletion. ElixirSense crashed because of unknown functions. The solution was to upgrade to Elixir 1.12.3 as suggested by this comment on GitHub.

During the upgrade, I decided to also upgrade Erlang and do a complete fresh installation of Erlang and Elixir on my M1 MacBook. Sadly, the tutorial I have been following before I have owned a M1 MacBook, didn't work any longer. Erlang didn't compile successfully because it was unable to find the wxmac and unixodbc libraries. I had to add some extra options to solve this.

I assume you have installed asdf already, but here is the full installation command I use after reading the Tutorial by Andres.

brew install asdf autoconf wxmac openssl fop coreutils \
             automake libyaml readline libxslt libtool \ 
             unixodbc unzip curl
Enter fullscreen mode Exit fullscreen mode

Next you have to set some extra environment variables that tell kerl where to find wxmac and unixodbc, like suggested by this comment on GitHub.

export CFLAGS="-O2 -g -fno-stack-check"
export KERL_CONFIGURE_OPTIONS="--disable-hipe --with-ssl=$(brew --prefix openssl) --with-wx-config=$(brew --prefix wxmac)/bin/wx-config --with-odbc=$(brew --prefix unixodbc)" 
export CPPFLAGS="-I$(brew --prefix unixodbc)/include"
export LDFLAGS="-L$(brew --prefix unixodbc)/lib"
Enter fullscreen mode Exit fullscreen mode

Now you are ready to install Erlang 24 and Elixir 1.12.3 using asdf.

asdf install erlang 24.0.6
asdf global erlang 24.0.6
asdf install elixir 1.12.3
asdf global elixir 1.12.3
Enter fullscreen mode Exit fullscreen mode

With Elixir 1.12.3 autocompletion works again for me.

P.S.: Of course you can also wait for the update of the homebrew elixir package, but I prefer to manage my environments using asdf.


Photo by Antonio Scalogna on Unsplash

Discussion (2)

Collapse
jprokay profile image
Julian Prokay

Great guide! Just ran through it on my M1 running Monterey version 12.3 (21E230) and made the following changes:
brew install wxwidgets instead of brew install wxmac
Had to change the openssl as well, so the flags changed as follows:
export KERL_CONFIGURE_OPTIONS="--disable-hipe --with-ssl=$(brew --prefix openssl@1.1) --with-wx-config=$(brew --prefix wxwidgets)/bin/wx-config --with-odbc=$(brew --prefix unixodbc)"

Collapse
maiquitome profile image
Maiqui Tomé 🇧🇷

I had to change openssl to openssl@1.1, so it worked :) Thanks for the tips :)