APB9785

APB9785

Creator of ECSx

Live Components suddenly not compiling, app crashing with UndefinedFunctionError

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.

Marked As Solved

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

Also Liked

azyzz228

azyzz228

I got the same message. Figured out the issue has to do with code editor. When I was adding route for liveview, my code editor (VSCode with elixir extensions) suggested modules (one of which is my LiveView module), then I click “enter” on it and code editor automatically imports alias MyApp.MyLiveViewComponent which basically screws up everything. then I go and delete the import, and voila, error is gone

APB9785

APB9785

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…

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.

Where Next?

Popular in Questions Top

tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
New

We're in Beta

About us Mission Statement