Joshua
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
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
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
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
The error suggests that it’s not finding the artifact it expects, but if that failed to compile it should show up in the output of
mix deps.compile --force. Weird.I don’t have an M1 to test with, but one way I imagine this could happen is if the dependency compilation and the
iexwere mismatched - one on Rosetta and the other not.Joshua
Did some digging around, found something interesting.
Firstly, I cloned the argon2_elixir GitHub onto my M1 Pro machine.
Fetched the dependencies, and ran
make.I’m not a C developer by any means, so I’m just relying on Stack Overflow, but it seems like some file is missing for some reason.
kip
I did a basic installation as you did but with different results!
My versions of
gccandmakeas the same as yours. I think I have the right binary format (all ARM64):Not sure what to try next, I’m well out of my depth now…
Joshua
Okay, so I took the dependency straight out of the /deps folder and use that instead. Got the same results as you.
So, I dug a little deeper and went looking around to see where the error was being thrown. Turns out it came down to this function:
So, I ran this code directly in the IEX shell, and this happened:
Looks like Erlang isn’t happy. Any good Erlang/C people that can parse this message?
kip
That message basically means what it says: you can’t call
:erlang.load_nif/2from anywhere except within anifmodule. So unfortunately we’re no further forward at this point.Joshua
Sorry, I ran this in the IEX shell
This time, I actually ran it in the module, and got this instead:
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.
gcc --version, and copy the target (in my case,arm64-apple-darwin21.2.0)/deps/argon2_elixir/Makefileand add this line:CFLAGS += -target (your target)mix.exsand change{:argon2_elixir: "~> 2.0"}to{:argon2_elixir, path: "deps/argon2_elixir"}zac
So… 2023 and this still appears to be a problem? Has anyone come up with a more elegant solution than hacking the deps/argon2_elixir/Makefile?
al2o3cr
The original poster included more detail about what happened in their update on the corresponding issue:
https://github.com/riverrun/argon2_elixir/issues/52
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.