Undefined function link/1 while following LV book: Compilation error in file lib/pento_web/live/wrong_live.ex

Hi,

I started to read the book Programming-Phoenix-LIveView. I created the Phoenix project Pento from chapter 1 "Get to Know LiveView.

When I entered the command: mix phx.server I got a compilation error.

== Compilation error in file lib/pento_web/live/wrong_live.ex ==
** (CompilationError in file lib/pento/wrong_live.ex:11: undefined function link/1 (expected
PentoWeb.WrongLIve to define such a function or for it to be imported, but none are 
available)

Any idea what went wrong?

Thanks in advance

Thiel

Looks like it might be a capitalization issue: PentoWeb.WrongLive

Hi codeanpeace,

Thanks for quick reaction. I made a typo error when writing my request.

I use Elixir 1.14.4 and OTP 24.

I also tried the code from the Intro / Pento file from the book. And now I got the following error:

== Compilation error in file lib/pento_web/views/error_view.ex ==
** (UndefinedFunctionError) function PentoWeb.view/0 is undefined or private
PentoWeb.view()
expanding macro: PentoWeb.using/1
lib/pento_web/views/error_view.ex:2: PentoWeb.ErrorView (module)
(elixir 1.14.4) expanding macro: Kernel.use/2
lib/pento_web/views/error_view.ex:2: PentoWeb.ErrorView (module)

I guess there must be readers of the chapter “Build a simple LiveView” of the LV book who have resolved this problem.

Best regards,

Thiel

Going off of how your app has an error_view.ex file, you’re likely running on older versions of Phoenix and LiveView. The book’s code assumes Phoenix v1.7 and that’s also when Phoenix changed how it handles views. Changelog for v1.7 — Phoenix v1.7.0

I’d suggest running mix local.phx to update your Phoenix project generator and then creating a new app.

https://hexdocs.pm/phoenix/Mix.Tasks.Local.Phx.html

2 Likes

HI codeanpeace,

I follow up your advice by running mix local.phx and the problem was solved!

Many thanks,

Thiel

1 Like