Mix phx.gen.auth is failing - (UndefinedFunctionError) function Mix.Tasks.Phx.Gen.Context.build/2 is undefined

When I try to run mix phx.gen.auth Account User users in that new project, I get the following error:

** (UndefinedFunctionError) function Mix.Tasks.Phx.Gen.Context.build/2 is undefined (module Mix.Tasks.Phx.Gen.Context is not available)
    Mix.Tasks.Phx.Gen.Context.build(["Account", "User", "users"], Mix.Tasks.Phx.Gen.Auth)
    lib/mix/tasks/phx.gen.auth.ex:98: Mix.Tasks.Phx.Gen.Auth.run/2
    (mix 1.14.0) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (mix 1.14.0) lib/mix/cli.ex:84: Mix.CLI.run_task/2

I have tried this on phx_new 1.6.15 and 1.7.0-rc.0. I am not sure what changed in my environment that would cause this. Sorry, I don’t have much more context than that, but if anyone knows or has seen this before, that would be great.

My problem was I have an old version of phx_gen_auth that was messing things up.

~/ElixirProjects $ ls ~/.mix/archives
hex-1.0.1		phx_gen_auth-0.7.0	phx_new-1.7.0-rc.0

Once I deleted phx_gen_auth-0.7.0 everything worked.

3 Likes