argon2 not available or yet to be defined

I’m trying to use argon2 for hashing passwords.
I’ve added {:argon2_elixir, "~> 2.4"} to defp deps in apps/webshop/mix.exs, and then I did mix deps.get.
In user.ex I try to call a method from argon2 like so:

defp put_password_hash(
    %Ecto.Changeset{valid?: true, changes: %{password: password}} =changeset
    ) do
    change(changeset, hashed_password: Argon2.hash_pwd_salt(password))

But it says “Argon2.hash_pwd_salt/1 is undefined (module Argon2 is not available or is yet to be defined)”

If I run iex -S mix phx.server I can use it just fine.

hash = Argon2.hash_pwd_salt("password")
iex(2)> Argon2.verify_pass("password", hash)

How should I define my dependency?

1 Like

What you’ve done sounds right. Have you restarted your iex session after doing mix deps.get ? If you do mix deps |grep argon2 do you see it on the list?

It also looks like you’re using an umbrella project, is the place you’re using the Argon2 module the same project as where it is defined as a dep?


If I run mix deps |grep argon2 I get:

frits@frits-virtual-machine:~/webshop_umbrella$ mix deps |grep argon2
* argon2_elixir 2.4.1 (Hex package) (mix)
  locked at 2.4.1 (argon2_elixir) 0e21f52a

I’ve added argon2 to mix.exs in apps/webshop and I want to use it in apps/webshop/lib/webshop/gebruiker_context/gebuiker.ex.

Is it your editor that is giving the message? From my experience restarting the editor after deleting the .elixir_ls folder solved the issue


That did the trick. Thanks for the help both of you!