#vscode debugging with hot-reloading

1 messages · Page 1 of 1 (latest)

radiant egret
#

hey everyone! im new to elixir and erlang. if i understand correctly elixir has the ability to load/reload parts of a code (i.e modules) without restarting the whole app

i thought that'd be a great way to debug fast, like i'd be able to make changes and see them apply without restarting the whole session. seems its not so seamless but i can run recompile manually in iex -S mix which works (btw is there a way to trigger this automatically on save?)

the thing is i cant do that with vscode's debugger (with elixirls) (putting it in debug console says error: undefined function recompile/0 so it seems i can either add breakpoints or have hot-reloading, is there a way to get both somehow?

thank u for ur help!

jagged willow
#

Phoenix has auto reloading built in for dev mode. I’m not sure how vscode/elixirls debugger actually works though, I don’t know anyone that uses it nor has it ever worked for me. It seems like something folks coming from other languages try to use more than anything that’s usually who’s asking the questions. I find it easier to just write tests and run them instead of using the debugger

#

But maybe if elixirls could attach to the running Phoenix node it would just work kinda

#

Erlang can definitely do that I paste in modules all the time to iex but never tried with debugger

#

A lot of times it’s still just easier to restart because just reloading the code doesn’t always set things up the same way as if you started the system from scratch

fresh sable
#

They might not be using Phoenix however.

radiant egret
#

yes im not using phoenix, what do elixir devs generally use for debugging if not elixirls

fresh sable
#

Generally, using a test case and dbg() if I am being honest.

radiant egret
#

how about the editor? is vscode the go-to editor for elixir or are there options with better support

jagged willow
#

Vscode is very popular

#

Most folks just don’t use the debugger I think. It would be interesting to see that refuted. I think a lot of it has to do with the concurrency abilities and the way things are built around it makes a debugger move difficult. Like each test is run in a different process some tests can run concurrently and if you have a breakpoint in a module they’re both hitting it could get annoying to trigger properly. Just one simple example that could be worked around but things like that

#

You might prefer to use tracing instead too that way you can see what’s happening with your code execution

radiant egret
#

i took a shot at doing it manually with iex -S mix and dbg() and while it works i couldnt get —dbg pry to work, maybe cos the dbg() was inside a GenServer

jagged willow
#

Yeah that’s exactly the sort of thing that makes debugger hard to use

radiant egret
#

i mean breakpoints through elixirls work but then hot-reloading as far as i can tell doesnt

tardy glade
#

If you have an iex> terminal available you can use IEx.Helpers.recompile/0

radiant egret
#

yup that works is there a way to automate this to be done on save, so its like html dev

pseudo tangle
radiant egret
#

woah it just works