Is there an Elixir editor with Debugger?

Is there any IDE or Editor that support Elixir/Phoenix/Ecto Debugging with breakpoints and watches and other stuff?

1 Like

I’ve never used it, but seems to be possible in VS Code via https://github.com/JakeBecker/elixir-ls, and emacs via https://github.com/emacs-lsp/dap-mode.

1 Like

Is there some guide/tutorial how to use breakpoints/watches with VSCode for Elixir programmers?

1 Like

I use the ElixirLS addon for VSCode, but the debugging plugin has real issues. The main problem here is the fact that an Elixir app has several processes running concurrently and in parallel, so the debugger often goes completely bananas.

And never mind setting up the configurations, that’s uncharted territory few actually understand.

Unfortunately, as fair as I know, nothing beats using an IO.puts

5 Likes

I mostly use IEx.pry/0

5 Likes

I feel like tracing (or even IO.inspecting) makes a lot more sense than step-by-step debugging in Elixir, mostly because of the concurrence, pausing a process in the middle of its operation is not something that would normally occur on the BEAM, and can have side effects that would make the scenario totally different from the one you are trying to repeat.

6 Likes

The IntelliJ Elixir plugin by @KronicDeth does have debugger integration. I have not used it much as I usually do as above, but it does work (last I tried it). I’m running OSX and Rubymine (since I use that for my day job). I’ve seen some post where Windows users are having some difficulties with the plugin, but Linux and Mac are fine.

2 Likes

My general advice for Erlang/Elixir programs is to never ever use a debugger. Instead rely solely on logs and the occasional tracing. Besides being concurrent there are two other reasons:

  1. no devops in their right mind would allow you to attach a debugger on a production system. Instead learn to rely on logs from the start. Can’t figure it out with your current logs ? Add more!
  2. a lure of functional programming is code correctness. By using small functions and pattern matching it is usually trivial to pin-point errors and these should mainly be pre-condition errors. Code too complicate ? Break them down into more functions.

Tracing is the main reason why no serious Elixir application should use POPs (plain old processes). With GenServer, GenStateMachine, GenEvent etc you can turn on/off tracing on the fly, in production and dev without worries.

Tracing is one of the great advantages of BEAM not really found in any other systems.

7 Likes

Elixir does not work with Linux and Intellij which is giving this error, init terminating in do_boot ({undef,[{elixir,start_cli,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}).

Might be something wrong in your setup. I’m using RubyMine and it’s working for me, although I don’t generally use it for the reasons already listed here. It does come in handy from time to time though.

FYI - I have a run config set up for phx.server and from there you can click debug instead of run. Not sure how you are trying to use it.

2 Likes

I’m using it for with or without Phoenix, that is Elixir only or with Ecto and Phoenix.

You still need to create a run configuration like a mix command or bash command that you can run from the run tool. If you can run it with the IDE, you should be able to debug using it too. Doesn’t have to be Phoenix.

If you are still stuck after following the docs on his GitHub page, PM him. He’s always been helpful for me when I had questions.

Please give sample configuration.

FIrst, make sure you have the Elixir and Erlang SDK’s set. If you don’t, a lot of the plugin functionality does not work. There is an open issue where you’ll have to manually edit the iml file. (https://github.com/KronicDeth/intellij-elixir/issues/1378). Once you have that done and restart the IDE, the plugin should be functional.

From the Run menu, select Edit configurations. In the templates, you should now see Elixir Mix options to start from. Hit the + sign to add a new config and select Elixir Mix as the template and just fill in the mix arguments box. Here’s min for running Phoenix via mix. Now when you exit the Edit Configuration screen, just select your new run config and instead of pressing the green arrow to ‘run’ it, click the green ‘bug’ icon to run it with the debugger. Assuming you’ve set debugger breakpoints by clicking in the left margin next to the line of executable code, the program will break and the debugger window highlight when execution stops on that line.

If you are running with pure Elixir, please see the instructions in the plugin readme.md file. It explains all of this pretty thoroughly. https://github.com/KronicDeth/intellij-elixir#elixir-

2 Likes

did not work, Elixir is missing a good IDE, someone needs to step up.

I understand that you want something different than what you’ve found, but your comment here is unhelpful.

did not work

Out of their own kindness, people have given you detailed instructions with screenshots. “Did not work” is your response - no detail about what went wrong, error messages, etc. Anyone else who might have the same problem gets no help from you here in tracking it down further.

Elixir is missing a good IDE, someone needs to step up

People have mentioned editors with debuggers, as you asked about. To dismiss them as not “good” is rather rude. If they don’t suit your needs, give details on why.

Nobody “needs to step up” to make something for free just because you want it. You are not surrounded by cowardly people, afraid to “step up” and take responsibility for something that is morally imperative to do, as your comment seems to imply. People just don’t all want the same thing.

Here’s how you could respond more constructively:

Thanks everyone for taking the time to help me with this. Unfortunately I’m still having trouble. I tried [x], but I still get an error like [y] when I [z]. For context, I’m using [OS version, Elixir version, editor configuration, commands typed, etc].

and/or

I wish there were an IDE that [does blah]. If there are others out there who feel the same way, [let’s work together to build one | I don’t have the skills to build one myself, but I’d be happy to support you building one with funding and documentation help].

9 Likes

Hi, this is my first post. Struggling for days to get the IntelliJ Integration working.

I have tried the suggestions and still not working. Please guide me. I think I am missing something silly.


When I click run

When I click debug


Here is the full error message:

"C:\Program Files\erl10.1\bin\erl.exe" -pa "C:/Program Files/erl10.1/lib" -name debuggedb8d5d08a-494b-4136-a16f-cdf73e6a9358@127.0.0.1 -setcookie b8d5d08a-494b-4136-a16f-cdf73e6a9358 -eval application:ensure_all_started(elixir) -eval 'Elixir.Code':require_file(<<\"C:\Users\user\AppData\Local\Temp\intellij_elixir73\debugger\lib\intellij_elixir\debugger\server.ex\">>) -eval 'Elixir.Code':require_file(<<\"C:\Users\user\AppData\Local\Temp\intellij_elixir73\debugger\lib\intellij_elixir\debugged.ex\">>) -eval 'Elixir.Code':require_file(<<\"C:\Users\user\AppData\Local\Temp\intellij_elixir73\debugger\lib\mix\tasks\intellij_elixir\debug.ex\">>) -pa "C:/Program Files (x86)/Elixir/lib/eex/ebin" -pa "C:/Program Files (x86)/Elixir/lib/elixir/ebin" -pa "C:/Program Files (x86)/Elixir/lib/ex_unit/ebin" -pa "C:/Program Files (x86)/Elixir/lib/iex/ebin" -pa "C:/Program Files (x86)/Elixir/lib/logger/ebin" -pa "C:/Program Files (x86)/Elixir/lib/mix/ebin" -pa "C:/Program Files/erl10.1/lib/asn1-5.0.7/ebin" -pa "C:/Program Files/erl10.1/lib/common_test-1.16.1/ebin" -pa "C:/Program Files/erl10.1/lib/compiler-7.2.5/ebin" -pa "C:/Program Files/erl10.1/lib/crypto-4.3.3/ebin" -pa "C:/Program Files/erl10.1/lib/debugger-4.2.6/ebin" -pa "C:/Program Files/erl10.1/lib/dialyzer-3.3.1/ebin" -pa "C:/Program Files/erl10.1/lib/diameter-2.1.6/ebin" -pa "C:/Program Files/erl10.1/lib/edoc-0.9.4/ebin" -pa "C:/Program Files/erl10.1/lib/eldap-1.2.5/ebin" -pa "C:/Program Files/erl10.1/lib/erl_docgen-0.8.1/ebin" -pa "C:/Program Files/erl10.1/lib/erl_interface-3.10.4/ebin" -pa "C:/Program Files/erl10.1/lib/erts-10.1/ebin" -pa "C:/Program Files/erl10.1/lib/et-1.6.3/ebin" -pa "C:/Program Files/erl10.1/lib/eunit-2.3.7/ebin" -pa "C:/Program Files/erl10.1/lib/ftp-1.0.1/ebin" -pa "C:/Program Files/erl10.1/lib/hipe-3.18.1/ebin" -pa "C:/Program Files/erl10.1/lib/inets-7.0.2/ebin" -pa "C:/Program Files/erl10.1/lib/jinterface-1.9.1/ebin" -pa "C:/Program Files/erl10.1/lib/kernel-6.1/ebin" -pa "C:/Program Files/erl10.1/lib/megaco-3.18.4/ebin" -pa "C:/Program Files/erl10.1/lib/mnesia-4.15.5/ebin" -pa "C:/Program Files/erl10.1/lib/observer-2.8.1/ebin" -pa "C:/Program Files/erl10.1/lib/odbc-2.12.2/ebin" -pa "C:/Program Files/erl10.1/lib/os_mon-2.4.6/ebin" -pa "C:/Program Files/erl10.1/lib/otp_mibs-1.2.1/ebin" -pa "C:/Program Files/erl10.1/lib/parsetools-2.1.8/ebin" -pa "C:/Program Files/erl10.1/lib/public_key-1.6.2/ebin" -pa "C:/Program Files/erl10.1/lib/reltool-0.7.7/ebin" -pa "C:/Program Files/erl10.1/lib/runtime_tools-1.13.1/ebin" -pa "C:/Program Files/erl10.1/lib/sasl-3.2.1/ebin" -pa "C:/Program Files/erl10.1/lib/snmp-5.2.12/ebin" -pa "C:/Program Files/erl10.1/lib/ssh-4.7.1/ebin" -pa "C:/Program Files/erl10.1/lib/ssl-9.0.2/ebin" -pa "C:/Program Files/erl10.1/lib/stdlib-3.6/ebin" -pa "C:/Program Files/erl10.1/lib/syntax_tools-2.1.6/ebin" -pa "C:/Program Files/erl10.1/lib/tftp-1.0.1/ebin" -pa "C:/Program Files/erl10.1/lib/tools-3.0.1/ebin" -pa "C:/Program Files/erl10.1/lib/wx-1.8.5/ebin" -pa "C:/Program Files/erl10.1/lib/xmerl-1.3.18/ebin" -noshell -s elixir start_cli -elixir ansi_enabled true -extra "C:\Program Files (x86)\Elixir\bin\mix" do intellij_elixir.debug, run
init terminating in do_boot ({,[{Elixir.Code,find_file,2,[{_},{_}]},{Elixir.Code,require_file,2,[{_},{_}]},{erl_eval,do_apply,6,[{_},{_}]},{init,start_it,1,[{_},{_}]},{init,start_em,1,[{_},{_}]},{init

Crash dump is being written to: erl_crash.dump...{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.Code.LoadError',file=><<99,58,47,85,115,101,114,115,47,117,115,101,114,47,68,114,111,112,98,111,120,47,69,108,105,120,105,114,32,80,114,111,106,101,99,116,115,47,76,101,97,114,110,95,95,47,108,101,97,114,110,95,101,108,105,120,105,114,47,85,115,101,114,115,117,115,101,114,65,112,112,68,97,116,97,76,111,99,97,108,84,101,109,112,105,110,116,101,108,108,105,106,95,101,108,105,120,105,114,55,51,127,101,98,117,103,103,101,114,108,105,98,105,110,116,101,108,108,105,106,95,101,108,105,120,105,114,127,101,98,117,103,103,101,114,32,101,114,118,101,114,46,101,120>>,message=><<99,111,117,108,100,32,110,111,116,32,108,111,97,100,32,99,58,47,85,115,101,114,115,47,117,115,101,114,47,68,114,111,112,98,111,120,47,69,108,105,120,105,114,32,80,114,111,106,101,99,116,115,47,76,101,97,114,110,95,95,47,108,101,97,114,110,95,101,108,105,120,105,114,47,85,115,101,114,115,117,115,101,114,65,112,112,68,97,116,97,76,111,99,97,108,84,101,109,112,105,110,116,101,108,108,105,106,95,101,108,105,120,105,114,55,51,127,101,98,117,103,103,101,114,108,105,98,105,110,116,101,108,108,105,106,95,101,108,105,120,105,114,127,101,98,117,103,103,101,114,32,101,114,118,101,114,46,101,120>>},[{'Elixir.Code',find_file,2,[{file,"lib/code.ex"},{line,1147}]},{'Elixir.Code',require_file,2,[{file,"lib/code.ex"},{line,754}]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]},{init,start_it,1,[{file,"init.erl"},{line,1125}]},{init,start_em,1,[{file,"init.erl"},{line,1111}]},{init,do_boot,3,[{file,"init.erl"},{line,819}]}]}}
done

The same config works with:
iex.bat -S mix

And then runs in there.

Any suggestions on what to do?

1 Like

It looks like the file paths are Windows, I know there used to at least be issues on windows, unsure if still is. Can you test on a posix style system?

2 Likes

Tracing is the main reason why no serious Elixir application should use POPs (plain old processes). With GenServer , GenStateMachine , GenEvent etc you can turn on/off tracing on the fly, in production and dev without worries.

This sounds really cool. What should I read to understand how to accomplish this?

Agree with OvermindDL1 - in the output of that message you can see there are quite a few paths with forward slashes.

I’ve no experience with IntelliJ, but I can see from the initial screen shot on the configuration page there are fields that allow you to pass arguments to the executable (at least I assume that’s what those are).

Looking at the error I can see arguments passed to the executable i.e. the big list of stuff you can see after “C:\Program Files\erl10.1\bin\erl.exe” in your error message, many of which are not valid paths for the Windows OS. I don’t know which ones are which, but I suspect that if you haven’t configured anything else elsewhere in IntelliJ these could be added to your configuration.

Edit: a quick re-read of this post and I can see that drl123 has made some great suggestions regarding configuration and a very quick glance through the plugin’s documentation could suggest the problem is with how the SDK configuration has been setup - just an idea :slight_smile:

2 Likes