Joshua

Joshua

Argon2_elixir will not run on Apple Silicon

Using macOS Monterey 12.1 with M1 Pro.

Elixir version:

$ elixir --version
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [dtrace]

Elixir 1.13.1 (compiled with Erlang/OTP 24)

Argon2 just doesn’t seem to want to compile.
Whenever I try to use Argon2, this happens:

iex(1)> Argon2.Base.init()
** (UndefinedFunctionError) function Argon2.Base.init/0 is undefined (module Argon2.Base is not available)
    (argon2_elixir 2.4.0) Argon2.Base.init()
iex(1)> 
20:37:46.896 [error] Process #PID<0.436.0> raised an exception
** (RuntimeError) An error occurred when loading Argon2.
Make sure you have a C compiler and Erlang 20 installed.
If you are not using Erlang 20, either upgrade to Erlang 20 or
use bcrypt_elixir (version 0.12) or pbkdf2_elixir.
See the Comeonin wiki for more information.

    (argon2_elixir 2.4.0) lib/argon2/base.ex:19: Argon2.Base.init/0
    (kernel 8.2) code_server.erl:1317: anonymous fn/1 in :code_server.handle_on_load/5
 
20:37:46.903 [error] Process #PID<0.438.0> raised an exception
** (RuntimeError) An error occurred when loading Argon2.
Make sure you have a C compiler and Erlang 20 installed.
If you are not using Erlang 20, either upgrade to Erlang 20 or
use bcrypt_elixir (version 0.12) or pbkdf2_elixir.
See the Comeonin wiki for more information.

    (argon2_elixir 2.4.0) lib/argon2/base.ex:19: Argon2.Base.init/0
    (kernel 8.2) code_server.erl:1317: anonymous fn/1 in :code_server.handle_on_load/5
 
20:37:46.897 [warning] The on_load function for module Elixir.Argon2.Base returned:
{%RuntimeError{
   message: "An error occurred when loading Argon2.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse bcrypt_elixir (version 0.12) or pbkdf2_elixir.\nSee the Comeonin wiki for more information.\n"
 },
 [
   {Argon2.Base, :init, 0,
    [file: 'lib/argon2/base.ex', line: 19, error_info: %{...}]},
   {:code_server, :"-handle_on_load/5-fun-0-", 1,
    [file: 'code_server.erl', line: 1317]}
 ]}

 
20:37:46.908 [warning] The on_load function for module Elixir.Argon2.Base returned:
{%RuntimeError{
   message: "An error occurred when loading Argon2.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse bcrypt_elixir (version 0.12) or pbkdf2_elixir.\nSee the Comeonin wiki for more information.\n"
 },
 [
   {Argon2.Base, :init, 0,
    [file: 'lib/argon2/base.ex', line: 19, error_info: %{...}]},
   {:code_server, :"-handle_on_load/5-fun-0-", 1,
    [file: 'code_server.erl', line: 1317]}
 ]}

I’ve already tried cleaning all dependencies, reinstalling them. I checked and yes I do have a C compiler. I’m starting to worry that this won’t work on Apple Silicon.

Any other suggestions? Thanks

Marked As Solved

Joshua

Joshua

I finally found out what it was. As someone suggested earlier in the thread, x86_64 binaries where being compiled instead of arm64 ones. Not sure why, but I found the fix.

  1. Run gcc --version, and copy the target (in my case, arm64-apple-darwin21.2.0)
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  1. Open /deps/argon2_elixir/Makefile and add this line: CFLAGS += -target (your target)
  2. Open mix.exs and change {:argon2_elixir: "~> 2.0"} to {:argon2_elixir, path: "deps/argon2_elixir"}

Also Liked

zac

zac

Ahhh. Ok, don’t have Rosetta installed here… found this running down related posts about M1 and argon2 failed compile issues. (None of which followed up w/ solutions…)

However… finally figured out what broke it. There’s a space in my project pathname. While that shouldn’t be a problem looks like it is – moved my project dir so no space, and getting a good compile.

So. Don’t use spaces. :confused:

Last Post!

leifertin

leifertin

This was it for me - I watched the deps/argon2 folder as I cleaned then recompiled. It added a folder with the second word of the parent’s parent folder.

Amazing it can win awards for being such a secure algorithm but can’t handle a space.

Where Next?

Trending in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
tj0
I’ve been following the steps here for the upgrade from 1.6 to 1.7 and it has gone relatively smoothly all the way till the phoenix_view ...
New
cgraham
Hi! What is currently the best library/method for parsing text and tabular data out of PDF files in Elixir or Erlang?
New
stefanchrobot
Hi, I need a way to handle data migrations in my application. I found an article by @wojtekmach about manual migrations: Automatic and ma...
New
stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
Squid Mesh is an open source workflow automation runtime for Elixir applications. It is aimed at Phoenix and OTP apps that want to defin...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

We're in Beta

About us Mission Statement