Compilation error after running phx.gen.auth for Phoenix 1.7

As I followed · GitHub for Phoenix migration from 1.6 to 1.7, I wanted to regenerate Authentication as I did touched it yet. When I run phx.gen.auth, it generates a bunch of files as expected (and changes some existing files), but compilation fails:

== Compilation error in file lib/myapp_web/controllers/user_session_html.ex ==
** (UndefinedFunctionError) function MyAppWeb.html/0 is undefined or private
    expanding macro: MyAppWeb.__using__/1
    lib/myapp_web/controllers/user_session_html.ex:2: MyAppWeb.UserSessionHTML (module)
    (elixir 1.15.4) expanding macro: Kernel.use/2
    lib/myapp_web/controllers/user_session_html.ex:2: MyAppWeb.UserSessionHTML (module)

Version of Elixir and Phoenix are up-to-date.

Does anyone have an idea how to fix this error? I have not found anything useful on the internet yet.

Thank you for any help!

Blind shot in the dark, have you tried re-running mix archive.install hex phx_new? Maybe that will download newer generator that won’t have the problem. Seems like the generated code is using something outdated.

You most likely forgot to add def html do and friends to your MyAppWeb module. It doesn’t seem to be mentioned in the guide, cause it is optional, but you can generate mix with a new Phoenix app and copy those bits. :slight_smile:


Hi, sorry for the delay, I was away for a while…
I will try your sugestions, thanks!