Phoenix 1.6.2, liveview 0.16.4: Changing root.html.leex to .heex and Router.init/1 is undefined

So I updated the project to Phoenix 1.6 and I tried changing root.html.leex to root.html.heex and changed

<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>

to

<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")}/>

run the app and GET /:

[info] GET /
[error] #PID<0.864.0> running FaithfulWordWeb.Endpoint (connection #PID<0.863.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function FaithfulWordWeb.Router.init/1 is undefined (module FaithfulWordWeb.Router is not available)
        FaithfulWordWeb.Router.init([])
        (faithful_word 0.1.0) lib/faithful_word_web/endpoint.ex:1: FaithfulWordWeb.Endpoint.plug_builder_call/2
        (faithful_word 0.1.0) lib/plug/debugger.ex:136: FaithfulWordWeb.Endpoint."call (overridable 3)"/2
        (faithful_word 0.1.0) lib/faithful_word_web/endpoint.ex:1: FaithfulWordWeb.Endpoint.call/2
        (phoenix 1.6.2) lib/phoenix/endpoint/cowboy2_handler.ex:43: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /Users/michael/src/phx/markably-media-feed/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /Users/michael/src/phx/markably-media-feed/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /Users/michael/src/phx/markably-media-feed/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 3.15.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

when I restore the suffix to .leex and the legacy syntax, the app can find the Router. So, not sure if it’s actually an issue with endpoint.ex

Any ideas how I debug this?

dependencies:

elixir 1.12.2-otp-24
erlang 24.0.3
nodejs 15.14.0
  phoenix 1.6.2
  phoenix_html 3.1.0
  phoenix_live_dashboard 0.5.3
  phoenix_live_reload 1.3.3
  phoenix_live_view 0.16.4
  phoenix_pubsub 2.0.0
  phoenix_view 1.0.0

Michael

Remove the _build folder and it should work. There is a bug in Elixir where renaming an external resource (such as leex to heex) is not picked up. This is fixed in the RC coming this week.

2 Likes

That nailed it, thanks!