Table of Contents
Recently, I decided to start learning Elixir. The first step in learning any language is to install the required tools. While installing elixir on a mac m1 machine, I ran into a lot of problems. This post is a quick guide on the issues I faced and how to fix them.
In retrospect, I should have not installed Elixir directly but should have installed Elixir via Nix. If you want a guide on that, check out this post by Rakshan .
If you anyway want to install Elixir directly, read on to find out the issues I faced. Hopefully, most of these issues should be fixed, but as of writing this post (October 2021), these issues are still present.
Things to make sure before installing Elixir
Before proceeding, make sure:
- You are not in a Rosetta shell. Also make sure that your
brewis pointing to/opt/homebrew/bin/brew. - You have the latest version of command line tools installed. Run
softwareupdate --all --install --forceto update it. - You have installed asdf.
If you try to install Elixir using brew install elixir as suggested in the official docs, it
will get installed, but you might face a segmentation fault after installing and running elixir --version. If that’s happening to you as well, check out this StackOverflow
Question .
These are the steps you need to follow:
- Install asdf if you haven’t already.
- Install the asdf erlang plugin .
- Make sure to read the “Before asdf install” section.
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
- Run
asdf install erlang latestand wait for erlang to build. - Run
asdf global erlang latest - Install the asdf elixir plugin .
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
- Install Elixir
asdf install elixir latest asdf global elixir latest- Run
iexorelixir --versionto test the installation.
Issues you might face while following the above steps
While trying to install Erlang, I faced a OpenSSL error -
checking for OpenSSL in /usr/local/opt/[email protected]... configure: error: neither static nor dynamic crypto library found in /usr/local/opt/[email protected]
This can be fixed by adding KERNEL CONFIG FLAG KERL_CONFIGURE_OPTIONS="--disable-parallel-configure"
I faced another error after fixing this one -
gen/wxe_wrapper_5.cpp:2165:29: error: taking the address of a temporary object of type 'wxBitmap' [-Waddress-of-temporary]
How to fix the wxe_wrapper error
This error is happening due to a problem in the code, as discussed in this github issue . To fix this, you need to overwrite the OTP tarball that asdf gives us with the fix in this commit .
- You will find the tarball at
~/.asdf/downloads/erlang/24.0/otp_src_24.0. - Extract the tarball using
tar -xzvf otp_src_24.0.tar.gz - Make the changes specified in the above commit in file
lib/wx/c_src/gen/wxe_wrapper_5.cpp. - Rebuild the tarball using
tar -czvf otp_src_24.0.tar.gz otp_src_24.0. - Now, run
asdf install erlang latestagain.
If you face any more errors that mention openssl or java, update the KERL_CONFIGURE_OPTIONS -
export KERL_CONFIGURE_OPTIONS="--with-ssl=/opt/homebrew/opt/[email protected] \
--with-wx-config=/opt/homebrew/opt/[email protected]/bin/wx-config \
--without-javac"
After this, Erlang should be installed. Install elixir as mentioned in the above steps. Make sure the elixir version u are installing is compatible with the erlang version you have installed. You can find the compatibility table here .