Erlang and Elixir on Apple Silicon/M1 Chip

Hello all!

I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily driver.

Wondering if anyone out there has had any luck installing elixir and Erlang using a version manager like asdf? I’ve been trying but getting a few build errors. If it takes considerable effort I’ll probably remote into a server to do whatever elixir development I need to until its more documented and better supported.

Thanks

4 Likes

Try compiling it from the GitHub repo, in particular, the maint branch, as there have been some fixes related to BigSur recently: https://github.com/erlang/otp/pull/2865

14 Likes

Thanks Jose!

I was able to get everything working by installing homebrew using rosetta 2. I followed this guide: https://soffes.blog/homebrew-on-apple-silicon

Still haven’t had much success installing older versions or using ASDF but 1.11 will work for what I need.

6 Likes

Homebrew has a compatibility tracker for several formulae.

2 Likes

Speaking of which, I wonder if the ERTS would work fine with asymmetric cores.

I see no reason why not, all is up to the system scheduler. It can be tested on LITTLE.big architecture from ARM (M1 uses similar approach).

Hi @albydarned,

I plan to buy an M1 Pro. My development is now pretty much only Elixir (Phoenix/LiveView etc). So if I can install Elixir using Homebrew (with Rosetta2), it seems I can push the Order button.

Am I right?
Thanks,
Dan

I have an experimental project that is a one click install of OTP+Elixir that you might find helpful:

$ curl -L -O https://wojtekmach.github.io/beamup/install.sh && bash install.sh

The script simply downloads precompiled OTP & Elixir releases. See https://github.com/wojtekmach/beamup. Currently the only available OTP release is 23.1.4 on , darwin-x86_64, darwin-arm64, linux-x86_64, and linux-armv7l (built on rpi4).

If you have a Mac with M1, this should work out of the box natively as well as via Rosetta 2.

As I mentioned initially, this is just a proof of concept. I had brief discussion with members of OTP team on attaching pre-compiled builds to new OTP releases, for macOS in particular. If GitHub ever exposes darwin-amd64 as a target, we’d definitely take advantage of that too.

That being said, you’d most likely want to use Homebrew for other things so it might make sense to use the unofficial support or wait for the official one. I’m personally trying out MacPorts this time around and it seems to work pretty well though it can’t install erlang yet.

5 Likes

NIce! The “about” link seems to be incorrect though.

thanks, fixed!

Has anyone here had success installing older versions of elixir or OTP?

Using brew to install elixir 1.11 has worked great, but I have some older projects I want to support.

Have you tried with asdf? There is an issue with OTP on BigSur but we can bypass that following Configure error with erlang 23.0.3 in MacOS 11 (Big sur) · Issue #161 · asdf-vm/asdf-erlang · GitHub

1 Like

Getting closer! Trying to install OTP 19.2 these are my results:

Followed this guide to create a rosetta terminal shortcut: https://osxdaily.com/2020/11/18/how-run-homebrew-x86-terminal-apple-silicon-mac/

Followed your link to edit the build and ran all commands in the rosetta terminal: https://github.com/asdf-vm/asdf-erlang/issues/161

Now i’m getting this error:

Build failed.
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/netinet6/in6.h:215:30: note: previous declaration is here
extern const struct in6_addr in6addr_loopback;

Something to do with xcode tools related to this issue: https://github.com/asdf-vm/asdf-erlang/issues/158

So far i’ve gotten 1.11 working using homebrew using the link I posted above. I don’t know if there are any nuances but it seems to be working.

1 Like

I just used Migration Assistant to transfer everything from my 2017 MBP to my new Mac mini. Whatever I had running with Elixir on the old system just works for me. I presume this is Rosetta 2 magic.

I had to launch VSCode twice. The first time the Elixir LS plugin crashed. Second time, no issues.

I’ve not tried to recompile or install the latest version yet. Was holding off for official main branch support because what I have works just fine for now.

2 Likes

I tried this Homebrew: GitHub - mikelxc/Workarounds-for-ARM-mac: This repository describes how I get most of my configurations work on the new Apple Silicon Mac

And brew install elixir, and then, I can install Elixir on Arm binary!

% file /opt/homebrew/Cellar/erlang/23.1.4/lib/erlang/erts-11.1.3/bin/erlexec
/opt/homebrew/Cellar/erlang/23.1.4/lib/erlang/erts-11.1.3/bin/erlexec: Mach-O 64-bit executable arm64

2 Likes

However, asdf doesn’t work. There are two issues, at least:

  1. It requires brew install curl, but it failed currently because installing sphinx-doc failed.
  2. asdf install erlang 23.1.4 raises an error while configure. To fix it according to https://github.com/asdf-vm/asdf-erlang/issues/161 , tar czvf OTP-23.1.4.tar.gz otp-OTP-23.1.4 doesn’t work due to an error: tar: Failed to clean up compressor
1 Like

I can confirm that installing elixir “just works” on a new Macbook Air M1 with a single brew install elixir for me when installing brew in /opt/homebrew (as advised by homebrew).

4 Likes

I made Elixir work using asdf on my M1 Macbook Air.

  • First setup asdf using the git install method.
  • Add the elixir and erlang plugins.
  • Run asdf install erlang latest this works without any modification.
  • asdf install elixir latest hangs though. To fix it run arch -x86_64 asdf install elixir latest to install with rosetta
2 Likes

A little thread necromancy here.

Decided to update to the M1 homebrew (/opt/homebrew install). Installed adsf. Used asdf to grab the latest Erlang.

And then I was able to use asdf install elixir latest. It worked without caveat.

6 Likes