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
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
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
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
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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

We're in Beta

About us Mission Statement