John_Shelby

John_Shelby

Compile error specific only for my Mac

Hi, I have a problem with compiling a project on my Mac. I’m experiencing the problem through all branches that were originally executable and no changes were made to them. Suddenly everything stopped working and I honestly have no idea what action could have caused this problem.

== Compilation error in file lib/my_app_web/controllers/user_switch_role_controller.ex ==
** (ArgumentError) defdelegate function is calling itself, which will lead to an infinite loop. You should either change the value of the :to option or specify the :as option
  (elixir 1.14.3) lib/kernel/utils.ex:32: Kernel.Utils.defdelegate_all/3
  /Users/username/Documents/Folder1/my_app/lib/my_app_web/controllers/user_switch_role_controller.ex:1: (file)
  (stdlib 4.2) erl_eval.erl:748: :erl_eval.do_apply/7
  (stdlib 4.2) erl_eval.erl:492: :erl_eval.expr/6
  (stdlib 4.2) erl_eval.erl:136: :erl_eval.exprs/6
  (filterable 0.7.4) /Users/username/Documents/Folder1/my_app/lib/my_app_web/controllers/user_switch_role_controller.ex:1: Filterable.__before_compile__/1

On my friend’s Mac everything is working fine. We both have a Mac M1 with OS Ventura 13.2.1. I can compile the same project on a Linux virtual machine without any problem.

Tool versions:
erlang 25.2.3
elixir 1.13.4-otp-25
nodejs 12.22.12
Steps I tried.

  • Uninstalling Elixir, Elrang and NodeJS, then the whole asdf. And then installing asdf and reinstalling Elixir, Erlang and NodeJS via asdf.
  • Reinstalling xcode.
  • Clone the project to a new folder

This is code from controller. Only def action.

defmodule MyAppWeb.UserSwitchRoleController do
 use MyAppWeb, :controller
 use Filterable.Phoenix.Controller

 alias MyApp.Users
 alias MyApp.Users.User

 def edit(conn, current_user, %{"id" => id}) do
  user = Users.get_user!(id)

  live_render(conn, MyAppWeb.UserLive.EditOwnRole, session: %{"user" => user})
 end

 def update(conn, current_user, %{"id" => id, "user" => user_params}) do
  user = Users.get_user!(id)

  case Users.update_user(user, user_params) do
   {:ok, user} ->
    conn
    |> put_flash(:info, gettext("User updated successfully."))
    |> redirect(to: Routes.user_switch_role_path(conn, :edit, user))

   {:error, %Ecto.Changeset{} = changeset} ->
    render(conn, "edit_own_role.html", user: user, changeset: changeset)
  end
 end

 def action(conn, _) do
  args = [conn, conn.assigns.current_user, conn.params]
  apply(__MODULE__, action_name(conn), args)
 end
end

I have defdelegate elsewhere in the app, but when I went through them, none of them even refer to the controller.
If it was explicitly a code error, wouldn’t it show up on a second Mac with the same setup?

Error def is here:
https://github.com/elixir-lang/elixir/blob/main/lib/elixir/lib/kernel/utils.ex

Anyone got any ideas? I would be glad for any help. :slightly_smiling_face:
Thanks.

Marked As Solved

al2o3cr

al2o3cr

The commit message doesn’t have much explanation, but I think this commit is related:

https://github.com/omohokcoj/filterable/pull/18

It adds an as: to the defdelegate in Filterable, which is brought in by Filterable.Phoenix.Controller.

Where Next?

Popular in Questions Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
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
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

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
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

We're in Beta

About us Mission Statement