There are already too many articles about Debugging with IEx on the web, so I will just get to the point straight.
FYI: As per Jose, Pry is not a debugger. It just allows you to interact with a particular context. https://stackoverflow.com/questions/33203676/iex-pry-going-step-by-step
add a breakpoint in your code:
require IEx; IEx.pry()
continue to the next breakpoint:
continue the execution of code without hitting any other breakpoints:
add a breakpoint to a function:
IEx.break!(Module, :function, arity) eg IEx.break!(String, :length, 1)
know your breakpoints current location:
open the code in the editor:
list out all the methods of a module:
helper functions like
whereamiare only available inside pry session.
openwon't work with precompiled source code
You need to configure either
EDITORenv variable for
It would make your life easier if you would configure a couple of things.
- Enabling History
If you want to have access to the commands you typed in your previous iex session, then add this
export ERL_AFLAGS="-kernel shell_history enabled" to your
.bashrc file and
source .bashrc. You won't get your shell history if you had terminated the previous IEx session by pressing
Ctrl + c two times. The right way to exit IEx session is to
ctrl g + q
- Customizing your IEx
You can customize your IEx by creating
.iex.exs file. This file gets executed every time you run IEx.
IO.puts """ ` ;: `+; ++', .+++, :'++'. .+'++'; Welcome to elixir-land ,+'+''': `:+'+';';; http://elixir-lang.org ,:++';;;;'. http://www.phoenixframework.org/ ::'+';;;;'' https://hex.pm/ :;;++;;';'' http://www.elixirschool.com/ .;;'''';;;: https://github.com/christopheradams/elixir_style_guide ,:::'';,,. ,,,,,:::, ,,,,,,, ``.` """ IEx.configure( alive_prompt: "%prefix(%node):%counter>", default_prompt: "%prefix:%counter>", inspect: [pretty: true, char_lists: :as_lists, limit: :infinity], history_size: -1, colors: [ ls_directory: :cyan, ls_device: :yellow, doc_code: :green, doc_inline_code: :magenta, doc_headings: [:cyan, :underline], doc_title: [:cyan, :bright, :underline], eval_result: [ :cyan, :bright ] ] ) import_file_if_available(".secret.exs") rs = fn -> Process.exit(self(), :normal) end