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’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
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 there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
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
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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.