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

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
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
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
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

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement