chrismccord / phoenix_live_view_example

538 stars 187 forks source link

Update to phoenix `master` to avoid runtime errors with `Phoenix.Template.hash` #27

Closed aforward closed 5 years ago

aforward commented 5 years ago

Here's what I am observing when starting the app

iex -S mix phx.server

Under a few scenarios.

As-Is

If you just grab the dependencies as-is

mix deps.get

You get the following error

** (UndefinedFunctionError) function Phoenix.Template.hash/3 is undefined or private. Did you mean one of:

      * hash/1
      * hash/2

    (phoenix) Phoenix.Template.hash("lib/demo_web/templates/error", "*", %{eex: Phoenix.Template.EExEngine, exs: Phoenix.Template.ExsEngine, leex: Phoenix.LiveView.Engine})
    lib/demo_web/views/error_view.ex:1: DemoWeb.ErrorView.__phoenix_recompile__?/0
    (elixir) lib/stream.ex:476: anonymous fn/4 in Stream.filter/2
    (elixir) lib/enum.ex:3317: Enumerable.List.reduce/3
    (elixir) lib/stream.ex:1568: Enumerable.Stream.do_each/4
    (elixir) lib/enum.ex:3015: Enum.reverse/1
    (elixir) lib/enum.ex:2647: Enum.to_list/1
    (phoenix) lib/mix/tasks/compile.phoenix.ex:13: Mix.Tasks.Compile.Phoenix.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.all.ex:68: Mix.Tasks.Compile.All.run_compiler/2
    (mix) lib/mix/tasks/compile.all.ex:52: Mix.Tasks.Compile.All.do_compile/4
    (mix) lib/mix/tasks/compile.all.ex:23: anonymous fn/1 in Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.all.ex:39: Mix.Tasks.Compile.All.with_logger_app/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.ex:96: Mix.Tasks.Compile.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/app.start.ex:58: Mix.Tasks.App.Start.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/run.ex:130: Mix.Tasks.Run.run/5
    (mix) lib/mix/tasks/run.ex:86: Mix.Tasks.Run.run/1

Updating Dependencies

If you keep mix.exs as-is, but update all dependencies

mix deps.update --all

You get that same error above.

Latest lastes

If you update mix.exs to reference master for phoenix, and grab the dependencies

mix deps.update --all

Then it works as expected.

[debug] Live reload: priv/static/js
[debug] Live reload: priv/static/css
[debug] Live reload: priv/static/js/app.js
[debug] Live reload: priv/static/css/app.css
[debug] Live reload: priv/static/images/phoenix.png
   13 modules
[debug] Tzdata polling for update.
[debug] Tzdata polling shows the loaded tz database is up to date.
[info] GET /
[debug] Processing with DemoWeb.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 30ms
[info] CONNECT Phoenix.LiveView.Socket
  Transport: :websocket
  Connect Info: %{}
  Parameters: %{"vsn" => "2.0.0"}
[info] Replied Phoenix.LiveView.Socket :ok
[info] Replied phoenix:live_reload :ok
chrismccord commented 5 years ago

Phoenix 1.4.4 should be fine in this case. I'm not sure what is causing the error, but did you try to mix clean and rebuild?