Need help Error Phoenix.View.render/3 is undefined

Need help for below errors


(UndefinedFunctionError) function Phoenix.View.render/3 is undefined (module Phoenix.View is not available)
Phoenix.View.render(MyWebApp.LayoutView, "_app_v3.html", %{})
(phoenix 1.7.2) lib/phoenix/controller.ex:1010: anonymous fn/5 in Phoenix.Controller.template_render_to_iodata/4
(telemetry 1.2.1) /app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
(phoenix 1.7.2) lib/phoenix/controller.ex:976: Phoenix.Controller.render_and_send/4
(phoenix 1.7.2) lib/phoenix/endpoint/render_errors.ex:84: Phoenix.Endpoint.RenderErrors.instrument_render_and_send/5
phoenix 1.7.2) lib/phoenix/endpoint/render_errors.ex:62: Phoenix.Endpoint.RenderErrors.__catch__/5

Add {:phoenix_view, "~> 2.0"} to your mix.exs. Is a required step when migrating to Phoenix v1.7.

2 Likes

I have added {:phoenix_view, “~> 2.0”} in mix.exs while migrating to Phoenix V1.5, but it gives issues while pushing the code, there is no issues in the local environment.

Please supply more details (error logs) about the issues you’re experiencing. There is nothing to guide anybody any further.

2 Likes

I am migrating Elixir version from 1.10 to 1.12, and Phoenix v1.4 to 1.5.
Also I have upgraded image version for the same.

The application is working fine in dev environment, but while pushing from dev to QA, I am getting above error.
After migrating I am getting errror

(UndefinedFunctionError) function Phoenix.View.render/3 is undefined (module Phoenix.View is not available)
Phoenix.View.render(MyWebApp.LayoutView, “_app_v3.html”, %{})
(phoenix 1.7.2) lib/phoenix/controller.ex:1010: anonymous fn/5 in Phoenix.Controller.template_render_to_iodata/4
(telemetry 1.2.1) /app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
(phoenix 1.7.2) lib/phoenix/controller.ex:976: Phoenix.Controller.render_and_send/4
(phoenix 1.7.2) lib/phoenix/endpoint/render_errors.ex:84: Phoenix.Endpoint.RenderErrors.instrument_render_and_send/5
phoenix 1.7.2) lib/phoenix/endpoint/render_errors.ex:62: Phoenix.Endpoint.RenderErrors.catch /5

Below is my config file

config :my_future_now, MyWebApp.Endpoint,
render_errors: [view: MyWebApp.ErrorView, accepts: ~w(html json pdf)]

In error_view.ex

def render(“500.html”, _assigns) do
render(“500_internal_server_error.html”, %{})
end

In 500_internal_server_error.html.pug page :

body
= render LayoutView, “_app_v3.html”

Hmm, as a sanity check – the stacktrace suggests that you are migrating to v1.7 and not v1.5, is that what you set out to do?

And since it’s working fine in your dev environment but not QA environment after adding the phoenix_view dependency, have you double checked that the CI/CD pipelines run mix deps.get for your QA environment?

3 Likes

Not sure why the version shows phoenix 1.7.2 in error, but I have migrated to Phoenix v1.5 not 1.7.

Yes, CI/CD pipelines runs mix deps.get and mix deps.compile.

I am unable to find the root cause of this issue.

If the code says 1.7.2 in the stacktrace, then you are running 1.7.2. Try calling mix deps and confirming which version Phoenix is running on.

3 Likes

I have fixed this issue by removing layout: false from render_errors in config.ex

Thank you all for your support.

1 Like