Logo

dev-resources.site

for different kinds of informations.

Perfect Steps of Installing Erlang and Elixir to Apple Silicon Mac (2021 Dec edition)

Published at
12/17/2021
Categories
elixir
erlang
macos
asdf
Author
zacky1972
Categories
4 categories in total
elixir
open
erlang
open
macos
open
asdf
open
Author
9 person written this
zacky1972
open
Perfect Steps of Installing Erlang and Elixir to Apple Silicon Mac (2021 Dec edition)

In this article, I'll show the perfect steps of installing Erlang and Elixir to Apple Silicon Mac from scratch using Homebrew and asdf.

1. Upgrade macOS (if M1)

You can skip this step for M1 Pro/Max.

If M1, pre-installed macOS is Big Sur. So, first of all, you need to upgrade macOS into Monterey 12.1. However, upgrading from the pre-installed macOS Big Sur to Monterey will be failed due to the defect of the installer of Monterey. So, you should update Big Sur as the first step. Next, upgrade it into Monterey 12.0.1. Next, update it into Monterey 12.1.

2. Install Xcode 13.2.1 (optional)

You can skip this step even though you will install Homebrew.

Install Xcode 13.2.1 by App store.

3. Install Homebrew

  1. Launch terminal.
  2. Install Homebrew according to the official website.
  3. Run commands shown in the output results after installation.

The commands mentioned above are as follows (it requires your login password by sudo):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ${ZDOTDIR:-~}/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Enter fullscreen mode Exit fullscreen mode

Be sure to check and use the installation procedure on the official website and the commands displayed after installation.

4. Install Erlang and Elixir by Homebrew

Run the following commands at the terminal:

brew update
brew install elixir
Enter fullscreen mode Exit fullscreen mode

These commands install the latest Erlang and Elixir. If you use only the latest ones, these commands will be the easiest.

4'. Install only Erlang by Homebrew

If you want to install only Erlang, run the following commands at the terminal:

brew update
brew install erlang
Enter fullscreen mode Exit fullscreen mode

4''. Install Erlang and Elixir by asdf

Unfortunately, the installation procedure on the official website gets incomplete: unlinked to wx and odbc, lack of documents, etc.

4''-1. Install asdf by Homebrew

Install asdf by Homebrew according to the official website. I'll show the commands as follows, but you should check the official website:

brew install asdf
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
source ${ZDOTDIR:-~}/.zshrc
Enter fullscreen mode Exit fullscreen mode

4''-2. Install Erlang by asdf

This step is the most important. Firstly, install pre-requisite libraries:

asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
brew install wxwidgets
brew install openjdk
echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ${ZDOTDIR:-~}/.zshrc
source ${ZDOTDIR:-~}/.zshrc
brew install fop
Enter fullscreen mode Exit fullscreen mode

Then, set the environment variables KERL_CONFIGURE_OPTION, CC and LDFLAGS as follows:

export KERL_CONFIGURE_OPTIONS="--with-ssl=$(brew --prefix [email protected]) --with-odbc=$(brew --prefix unixodbc)"
export CC="/usr/bin/clang -I$(brew --prefix unixodbc)/include" 
export LDFLAGS=-L$(brew --prefix unixodbc)/lib
Enter fullscreen mode Exit fullscreen mode

If you will install Erlang/OTP 24.2+ and use OpenSSL 3, install OpenSSL 3 and reset KERL_CONFIGURE_OPTION:

brew install openssl@3
export KERL_CONFIGURE_OPTIONS="--with-ssl=$(brew --prefix openssl@3) --with-odbc=$(brew --prefix unixodbc)"
Enter fullscreen mode Exit fullscreen mode

I got the solution to link odbc by referring this issue: https://github.com/asdf-vm/asdf-erlang/issues/191

Next, if you'll install the latest one, run the following commands:

asdf install erlang latest
asdf global erlang latest
Enter fullscreen mode Exit fullscreen mode

You can get the versions that can be installed as follows:

asdf list-all erlang
Enter fullscreen mode Exit fullscreen mode

Unfortunately, some specific older versions cannot be installed into Apple Silicon Mac.

If you'll install OTP 22, follow this issue: https://github.com/asdf-vm/asdf-erlang/issues/221

After installation, unset CC and LDFLAGS:

unset CC LDFLAGS
Enter fullscreen mode Exit fullscreen mode

4''-3. Install Elixir by asdf

Install the Elixir plugin by asdf according to the official website.

asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
Enter fullscreen mode Exit fullscreen mode

Next, if you'll install the latest one, run the following commands:

asdf install elixir latest
asdf global elixir latest
Enter fullscreen mode Exit fullscreen mode

You can get the versions that can be installed as follows:

asdf list-all elixir
Enter fullscreen mode Exit fullscreen mode

Summary

You'll get Elixir and Erlang on Apple Silicon as the steps mentioned above.

asdf Article's
30 articles in total
Favicon
📦 ASDF: Gerenciando versões de linguagens e ferramentas num lugar só
Favicon
MCP using node on asdf
Favicon
asdfasdf
Favicon
Migrating from nvm to mise
Favicon
The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 2
Favicon
Install ASDF on Mageia 9
Favicon
asdf (what?? 🤔)
Favicon
Install Ruby and Rails on Fedora 40
Favicon
Install mutiple Erlang and Elixir with vfox
Favicon
Installing Erlang With vfox
Favicon
Getting Started with Ruby: A Beginner's Guide to Installation and Basic Programs
Favicon
ASDF
Favicon
Cool Tool: ASDF — A single solution for managing versions
Favicon
PHP on Manjaro with ASDF
Favicon
Criando seu ambiente com ASDF
Favicon
asdf, python and automatically enabling virtual envs
Favicon
Rails 基礎 Part 00 -- asdf と ruby を動かす
Favicon
Beginner's Guide to rtx (mise)
Favicon
Using asdf to manage my development tools
Favicon
"asdf" multiple runtime version manager to install node.js
Favicon
Install Ruby 3.2.0 + YJIT with ASDF
Favicon
Raku on asdf
Favicon
asdf Basics & Cheat Sheet
Favicon
Setup asdf & direnv
Favicon
migrate from nvm to asdf
Favicon
Elixir - Configurando o Setup
Favicon
Ruby on Rails: Switch From sqlite3 to Postgres using asdf
Favicon
A Must-Have Tool For Developers.
Favicon
ASDF: O gerenciador de versões universal!
Favicon
Perfect Steps of Installing Erlang and Elixir to Apple Silicon Mac (2021 Dec edition)

Featured ones: