Is there an Elixir editor with Debugger?

ecto
erlang
phoenix
learning-elixir

#1

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


#2

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.


#3

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


#4

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

I mostly use IEx.pry/0


Profiling memory usage in given process
#6

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.


#7

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.


#8

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.


#9

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,[]}]}).


#10

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.


#11

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


#12

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.


#13

Please give sample configuration.


#14

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-


#15

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