2
votes

Attempting to debug a project using IEx.pry, I found that I need to use the --werl flag. I would refer anyone with potential solutions to this discussion to:

Should --werl be made default?

My current project has multiple modules and uses Plug.Router. I realize that prying may not be the best debugging technique in this case. Still...

I was curious to learn how to debug with pry so I tested a simple case very similar to this solution. In short, prying variables from the process environment requires that the IEx shell be running during compile time. This works fine for single modules like in the example linked above; however, my current project requires that I mix the project directory. Correct me, perhaps there is a verbose way to compile and run a project directory in the erlang console? At any rate, neither mix run --no-halt nor iex -S mix run work for prying on Windows (the latter requesting the --werl flag).

I then attempted the same task on a much simpler project that did not use Plug and only has one module, a recursive counter. Still, I could not iex -S mix this with the --werl flag. The Erlang console opens, closes, and the application is not started. ddddd I am deducing that I cannot mix a project directory with the --werl flag, but then when should I use it? And how can I pry in the IEx shell? I would rather not use the Erlang console at all if it is possible.

Reading the Hex docs for IEx:

Such function [Enum in their example] may not be available on some Windows shells. You may need to pass the --werl flag when starting iex, as in iex --werl for it to work. --werl may be permanently enabled by setting the IEX_WITH_WERL environment variable.

The docs say no more about when to use the --werl option.

Clearly, I am new to Elixir, but this does not seem like an obvious distinction even though this issue was raised some 2 years ago.

1

1 Answers

1
votes

When you want to use both --werl and -S mix together, you have to put --werl before the -S mix.

iex --werl -S mix will work while iex -S mix --werl won't work.