SMOLNET PORTAL home about changes

Making dbg/2 useful in IEx


April 17, 2023

The default behavior of `dbg/2` when running an application via IEx (e.g. `iex -S mix phx.server`) is to halt execution and request to `pry` into the executing context.

However, in most cases I just want dbg/2 to behave a like a fancier `IO.inspect/2`.

This can be accomplished by adding this configuration to `~/.iex.exs`:

# Change behavior of dbg/2 to stop prying when in IEx
Application.put_env(:elixir, :dbg_callback, {Macro, :dbg, []})



[1] dbg/2 (https://hexdocs.pm)
[2] pry/0 (https://hexdocs.pm)
[3] IO.inspect/2 (https://hexdocs.pm)



Home
Posts
Pursuits
About


View on the web (https://www.schrockwell.com)
Response: 20 (Success), text/gemini
Original URLgemini://gmi.schrockwell.com/posts/2023-04-17-making-dbg-...
Status Code20 (Success)
Content-Typetext/gemini; charset=utf-8