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).
I made Elixir work using asdf on my M1 Macbook Air.
- First setup
asdf
using the git install method. - Add the
elixir
anderlang
plugins. - Run
asdf install erlang latest
this works without any modification. -
asdf install elixir latest
hangs though. To fix it runarch -x86_64 asdf install elixir latest
to install with rosetta
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.
Also another update from me then
Most intellij products are updated to M1 versions days ago, so now you can also use their intellij + elixir plugin native on the M1 machines. They came up in the intellij toolbox under a different name next to the old ones e.g. ‘Intellij IDEA Ultimate for Apple Silicon’.
VSCode(+elixirLS) was already working native if you use the ‘exploration’ / insiders build (see https://code.visualstudio.com/insiders/ small download link for ARM64).
I spoke too soon. It would appear that comeonin will compile with an older intel version of elixir (1.10.4-otp-23 in my case) Erlang (23.0.3 in my case), but fails on bcrypt when compiling on the latest elixir 1.11.2-otp-23 Erlang 23.2.1 for apple silicon.
Continuing investigation.
My particular issue was a VSCode architecture mismatch.
Posting the solution here in case anyone else experiences this side effect like I did.
Just wanna say this tutotial is awesome.
Very smooth fully native M1 Arm installation now via latest Homebrew and asdf-vm; be sure to install the Erlang dependencies autoconf
and wxmac
before installing Erlang, as specified in the asdf-erlang instructions.
Of note: the scheduler sees all 8 cores, including the low-power ones:
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
so it might be interesting to learn how that performs in practice.
Not sure if anyone’s seen this yet, but I’ve installed elixir 1.9 and erlang/otp 23 and almost all elixir compilation errors are swallowed and only a single stack-less “argument error” is spat out, ie:
== Compilation error in file test/support/factory.ex ==
** (ArgumentError) argument error
Even when I compile on the same machine in docker, the compilation errors are reported correctly, so it might actually be a Big Sur issue, but I have no idea as to the root cause.
Hopefully this is of use/interest to someone.
How I got Elixir/Phoenix working on an Apple M1
[MacBook Pro (M1 2020), chip Apple M1, MacOS Big Sur 11.3.1]
I installed the latest Elixir/OTP with Homebrew
$ brew install elixir
but found that my Phoenix projects wouldn’t run.
Eg. GitHub - pdxrod/article_editor
failed with
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
So I tried starting with a simpler project,
This had a different issue, to do with Mongo and its Elixir driver
{:mongodb, "~> 0.5.1"}
https://hexdocs.pm/mongodb/readme.html
The latest Elixir downloaded by Homebrew was 1.12.1, with Erlang/OTP 24. My project was created using Elixir 1.11.2, with Erlang/OTP 23.
The MongoDb driver 0.5.1 uses crypto.hmac/2, and OTP 24 wants crypto.hmac/3, so the project wouldn’t compile and run.
** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
Attempts to upgrade plug_crypto, as recommended here, made no difference.
I couldn’t figure out how to downgrade Elixir and Erlang using Homebrew, asdf, kiex, kurl or exenv. So I deleted all copies of both, and switched to using Macports.
sudo port install erlang @23.1
sudo port install elixir @1.11.2
mix deps.get
mix phx.server
Bingo!
This tells you how to install a given version of something with Macports
I installed Macports by finding MacPorts-2.7.1-11-BigSur.pkg here
Release MacPorts 2.7.1 · macports/macports-base · GitHub downloading and double-clicking on it.
Downgrading to Elixir 1.11 isn’t a permanent solution, so I’m going to look into other Mongo drivers, so see if any of them work with 1.12.
The crypto error can be easily addressed too, in case you want to submit a pull request. Here is how it was handled in plug_crypto: Use crypto new API (#20) · elixir-plug/plug_crypto@cf901bd · GitHub
For anyone wanting to run Elixir 1.11 and OTP 23 this guide worked well for me on an M1 Max in Monterey.
I made sure to install the latest homebrew, then asdf and plugins. Its key to do this from native terminal and NOT a rosetta terminal.
Could you please clarify, is Elixir and Erlang runs natively on M1? So no rosetta involved? And it means that it uses full CPU potential?
Thanks!
It does, I’ve set up Erlang 24.1.3 and Elixir .1.12.3 on both the MacBook pro 13inch M1 and the 14inch M1Max with no issues using asdf-vm
Depends on what you mean by “full potential”. BEAM do not support JIT on ARM64, so better performance of the CPU can be eaten by interpreting BEAM code instead of JITing.
it does on master and it is glorious.
I need to get my hands on M1 later and test that out.
When??
I just got my M1 MBP today and was slightly disappointed at the Elixir compile times (which is the main language I work with).
On the other hand… holy crap, a small Rust project went from 45s to 10s…
To get that kind of decrease in Elixir compile times… would be like heaven!
OTP 25 is still 6+ months out, but you can use the JIT right now if you build it with kerl. Runs great!
Hello! I tried installing Erlang/OTP with kerl
and Elixir with kiex
and didn’t notice any difference. How can I tell it’s working? I just installed 24.1.4 though… should I be giving kerl
a Github url and branch?
Thanks for the help!