fahani

fahani

Error while debugging Phoenix app. Ubuntu 24 + IntelliJ Ultimate

Hello!

I am a PHP and Go developer. This weekend I wanted to give it a try to Elixir & Phoenix but I run into some debugging issues that I am not able to resolve.

These are the versions of my current OS and tools:

  • Ubuntu 24.04.1 LTS
  • asdf v0.14.1-f00f759
  • Erlang 27.1
  • Elixir 1.17.3
  • Mix 1.17.3
  • IntelliJ IDEA 2024.2.2 (Ultimate Edition) Build #IU-242.22855.74, built on September 18, 2024
  • KronicDeth/intellij-elixir v19.0.1

I created a hello_elixir Phoenix project mix phx.new hello_elixir, I configured the db mix ecto.create and I started the app mix phx.server. I went to http://localhost:4000 and the app loaded correctly, here is the terminal output :

[info] Running HelloElixirWeb.Endpoint with Bandit 1.5.7 at 127.0.0.1:4000 (http)
[info] Access HelloElixirWeb.Endpoint at http://localhost:4000
[watch] build finished, watching for changes...

Rebuilding...

Done in 451ms.
[info] GET /
[debug] Processing with HelloElixirWeb.PageController.home/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 120ms

I made sure the app could run using Interactive Elixir iex -S mix phx.server, it ran correctly.

I went ahead and opened the project in the IDE and configure the Project Structure, here some screenshots (as a new user in the forum it won’t let me paste image directly):

Here is the debug configuration I tried:

Result of running the configuration:

/home/nico/.asdf/installs/erlang/27.1/bin/erl -pa /home/nico/.asdf/installs/erlang/27.1/lib/observer-2.16/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/tftp-1.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/kernel-10.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/megaco-4.6/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/wx-2.4.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/parsetools-2.6/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/os_mon-2.10/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ssh-5.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/mnesia-4.23.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/tools-4.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/stdlib-6.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/inets-9.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/snmp-5.17/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/diameter-2.4.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/edoc-1.3.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/asn1-5.3.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/odbc-2.15/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/syntax_tools-3.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/crypto-5.5.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/public_key-1.16.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/eldap-1.2.13/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/runtime_tools-2.1.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/eunit-2.9.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/debugger-5.4/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/erts-15.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/xmerl-2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/et-1.7.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/sasl-4.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ssl-11.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/common_test-1.27.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/compiler-8.5.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/erl_interface-5.5.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/jinterface-1.14.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ftp-1.2.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/dialyzer-5.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/reltool-1.0.1/ebin iex -S mix -name debuggeda68c5c05-5494-44b7-9ad8-8364f3aeb56a@127.0.0.1 -setcookie a68c5c05-5494-44b7-9ad8-8364f3aeb56a -eval application:ensure_all_started(elixir) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir10/debugger/lib/intellij_elixir/debugger/server.ex\">>) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir10/debugger/lib/intellij_elixir/debugged.ex\">>) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir10/debugger/lib/mix/tasks/intellij_elixir/debug.ex\">>) -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/elixir/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/ex_unit/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/iex/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/mix/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/logger/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/eex/ebin -noshell -s elixir start_cli -elixir ansi_enabled true -extra /home/nico/.asdf/installs/elixir/1.17.3/bin/mix do intellij_elixir.debug, phx.server
Error! Failed to load module 'mix' because it cannot be found.
Make sure that the module name is correct and that its .beam file
is in the code path.

Runtime terminating during boot ({undef,[{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
  • Unable to connect when going to http://localhost:4000/

Followed this Medium article or this post to create the debug configuration

If I run the configuration without erl arguments iex -S mix, this is the result:

/home/nico/.asdf/installs/erlang/27.1/bin/erl -pa /home/nico/.asdf/installs/erlang/27.1/lib/observer-2.16/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/tftp-1.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/kernel-10.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/megaco-4.6/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/wx-2.4.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/parsetools-2.6/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/os_mon-2.10/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ssh-5.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/mnesia-4.23.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/tools-4.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/stdlib-6.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/inets-9.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/snmp-5.17/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/diameter-2.4.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/edoc-1.3.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/asn1-5.3.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/odbc-2.15/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/syntax_tools-3.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/crypto-5.5.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/public_key-1.16.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/eldap-1.2.13/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/runtime_tools-2.1.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/eunit-2.9.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/debugger-5.4/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/erts-15.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/xmerl-2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/et-1.7.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/sasl-4.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ssl-11.2.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/common_test-1.27.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/compiler-8.5.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/erl_interface-5.5.2/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/jinterface-1.14.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/ftp-1.2.3/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/dialyzer-5.2.1/ebin -pa /home/nico/.asdf/installs/erlang/27.1/lib/reltool-1.0.1/ebin -name debuggede1784c9d-1d27-42b1-b06d-dbbdabade8eb@127.0.0.1 -setcookie e1784c9d-1d27-42b1-b06d-dbbdabade8eb -eval application:ensure_all_started(elixir) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir3/debugger/lib/intellij_elixir/debugger/server.ex\">>) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir3/debugger/lib/intellij_elixir/debugged.ex\">>) -eval 'Elixir.Code':require_file(<<\"/tmp/intellij_elixir3/debugger/lib/mix/tasks/intellij_elixir/debug.ex\">>) -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/elixir/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/ex_unit/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/iex/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/mix/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/logger/ebin -pa /home/nico/.asdf/installs/elixir/1.17.3/lib/eex/ebin -noshell -s elixir start_cli -elixir ansi_enabled true -extra /home/nico/.asdf/installs/elixir/1.17.3/bin/mix do intellij_elixir.debug, phx.server
     warning: single-quoted strings represent charlists. Use ~c"" if you indeed want a charlist or use "" instead
     │
 111 │       |> Stream.reject(&(&1 == '.'))
     │                                ~
     │
     └─ /tmp/intellij_elixir3/debugger/lib/intellij_elixir/debugger/server.ex:111:32

Waiting for debugger to attach...

11:57:02.776 [error] GenServer IntelliJElixir.Debugger.Server terminating
** (UndefinedFunctionError) function :int.interpreted/0 is undefined (module :int is not available)
    :int.interpreted()
    /tmp/intellij_elixir3/debugger/lib/intellij_elixir/debugger/server.ex:166: IntelliJElixir.Debugger.Server.handle_call/3
    (stdlib 6.1) gen_server.erl:2381: :gen_server.try_handle_call/4
    (stdlib 6.1) gen_server.erl:2410: :gen_server.handle_msg/6
    (stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message (from #PID<9302.4.0>): {:set_breakpoint, HelloElixirWeb.PageController, 7}
State: %IntelliJElixir.Debugger.Server{attached: nil, evaluate_meta_pid_to_froms: %{}}
Client #PID<9302.4.0> is remote on node :"debuggere1784c9d-1d27-42b1-b06d-dbbdabade8eb@127.0.0.1"

The break point is placed under the render in this module:

defmodule HelloElixirWeb.PageController do
  use HelloElixirWeb, :controller

  def home(conn, _params) do
    # The home page is often custom made,
    # so skip the default app layout.
    render(conn, :home, layout: false)
  end
end

Any guidance will be much appreciated.

Thank you!

First Post!

fahani

fahani

Tagging you @KronicDeth, in case you faced this before :pray:

Where Next?

Popular in Questions Top

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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
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
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
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
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
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
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

We're in Beta

About us Mission Statement