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
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.
- 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
- Open
/deps/argon2_elixir/Makefileand add this line:CFLAGS += -target (your target) - Open
mix.exsand change{:argon2_elixir: "~> 2.0"}to{:argon2_elixir, path: "deps/argon2_elixir"}
Also Liked
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. ![]()







