Debugging and debugging tools in Elixir?

You can use Quaff.Debug module from https://github.com/qhool/quaff

The Debug module provides a simple helper interface for running Elixir code in the erlang graphical debugger

I tested it today with Elixir 1.0.4, it works.


You can use IEx

require IEx

value = {:some, :erlang, :value}
IEx.pry

If you start this program with for example iex -s program.exs (or iex -S mix for a project) you'll be asked if you want to allow prying into this code when it is reached and value will be available for you for inspection.

You can also just do print debugging using IO.inspect allowing you to output basically any erlang data structure.


Debugging Cowboy apps, and Phoenix apps.

I saw this post in the Elixir rader http://www.jessetrimble.net/iex-pry-elixir, and thought i would just summarise it up here, as it's extremely convenient :-).

In Rails applications (and other), you can simply put in the debugger tag in your controller, and when the path is triggered, it will break at the debugger tag.

When using pry in Phoenix the above will result in

Cannot pry #PID<0.259.0> at web/controllers/posts_controller.ex:8. Is an IEx shell running?

It turns out that the Phoenix process must run within an IEx session, this is done as such

iex -S mix phoenix.server

Now instead you will see

Request to pry #PID<0.266.0> at web/controllers/posts_controller.ex:9. Allow? [Yn]

Tags:

Elixir