APB9785

APB9785

Creator of ECSx

I’ve been re-arranging my code to break a larger LiveView app into smaller Live Components based on separation of concerns. In the main app I alias the component module name (BoardComponent), then render:

<%= live_component @socket, BoardComponent,
      active_user: @active_user,
      user_cache: @user_cache,
      active_board: @active_board %>

I’ve done this with several different components so far, with no problems. But after doing a little work today, I’m suddenly getting hit with

** (UndefinedFunctionError) function MyAppWeb.BoardComponent.__live__/0 is undefined (module MyAppWeb.BoardComponent is not available)

But not just for the BoardComponent… when I try to access a different one - same exact error:

** (UndefinedFunctionError) function MyAppWeb.PostComponent.__live__/0 is undefined (module MyAppWeb.PostComponent is not available)

Even components that were not even touched by today’s work, for some reason are “not available”. And it’s really strange.. After reloading and recompiling a few times, I can get some modules to work but not others… and I’m not changing the code AT ALL - just killing and restarting mix phx.server gives different results each time.

Any ideas what could be going on? I didn’t really make any major changes today.

Showing Posts 1 to 10

petelacey

petelacey

Are you perhaps still using use Phoenix.LiveView when you should now be using use Phoenix.LiveComponent?

APB9785

APB9785 OP

Creator of ECSx

I’m using

use MyAppWeb, :live_component
APB9785

APB9785 OP

Creator of ECSx

I fixed my own issue by making non-changes
e.g. {:ok, socket} to:

{:ok,
  socket
}

doing that one-by-one for all my components, and Elixir then recompiled the files and now there are no errors. Even if I revert the changes back to {:ok, socket} it still works. Very strange…

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@APB9785 sounds like something in your _build directory got weird. While I generally find that compiler issues with Elixir are rare, when they do happen, they are generally fixed for me by doing rm -rf _build

Exadra37

Exadra37

Did you by any chance compiled the code or ran the app with different versions of Elixir:

  • like be trying out the app inside a docker container with the entire project mapped as a volume?
  • or by using your software version manager tool, like asdf to run the app with different Elixir version?

If you have done this then the _build folder get’s itself in a weird state. Also when trying out new versions of Elixir you may end-up with incompatible versions in your mix.lock and deps folder.

APB9785

APB9785 OP

Creator of ECSx

Thanks for the info! But in this case, I didn’t do anything with docker or asdf. I was just moving around some handle_event/3 clauses after separating a settings menu into its own LC.

Exadra37

Exadra37

So it seems that your solution is to do what is suggested here :slight_smile:

If you could replicate the issue in a sample Phoenix repo then you could open a bug report for the Elixir compiler.

jerdew

jerdew

I just came across this same error message and I don’t think I touched the code between working and not-working states. Walked away from the computer with no compile errors, came back and refreshed a webpage on localhost and it gave the same error as OP. I commented out a couple uncommitted changes (a route and the live_view file for that route) to remove all unstaged edits to get back to the commit that I’m sure was working, and the error persisted.

** (exit) an exception was raised:
    ** (UndefinedFunctionError) function MyAppWeb.CheckoutLive.Show.__live__/0 is undefined (module MyAppWeb.CheckoutLive.Show is not available)
        MyAppWeb.CheckoutLive.Show.__live__()
        (phoenix_live_view 0.17.5) lib/phoenix_live_view/static.ex:239: Phoenix.LiveView.Static.load_live!/2
        (phoenix_live_view 0.17.5) lib/phoenix_live_view/static.ex:83: Phoenix.LiveView.Static.render/3
        (phoenix_live_view 0.17.5) lib/phoenix_live_view/controller.ex:38: Phoenix.LiveView.Controller.live_render/3
        (phoenix 1.6.5) lib/phoenix/router.ex:355: Phoenix.Router.__call__/2
        (my_app_web 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2
        (my_app_web 0.1.0) lib/plug/debugger.ex:136: MyAppWeb.Endpoint."call (overridable 3)"/2
        (my_app_web 0.1.0) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2

Nuked the _build to get back to working before wondering if this was an error with a resolution. Are there useful commands/spelunking to do when a _build folder gets into a confused state?

elifous

elifous

I had exactly the same problem after some formatting changes at the live_component call. Deleting _build did not solve it. After deleting node_modules/.cache the error was gone. I also noticed some minor CSS issues also solved after deleting.

ghenry

ghenry

Deleting _build worked for me after copying an existing live module to a new file name.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews