MarkMekhaiel
Redefining modules in iex - does the original revert after leaving the session?
Hey
I have an elixir / phoenix application that I often connect to remotely.
I sometimes need to bugfix on there, and it helps me if I can insert some IO.inspects into modules to see what’s going on.
If I redefine that module inside the iex session, then it obviously picks up the new module and uses that code, overwriting the one in the codebase while I’m in the session.
My question is, once I leave that iex session, will the app use the new module I’ve defined or the one in the codebase?
Thanks in advance
Marked As Solved
NobbZ
If by ending iex you also end the application, your changes are lost.
If you attached to some otherwise running node then the changes will persist until that node gets restarted or otherwise a code reoload triggered.
Also Liked
LostKobrakai
It will continue to use the modified module until the node itself stops. On restart the node will expectedly load the module from disk again.
dimitarvp
That’s what I meant and I didn’t word it properly as I was in a rush. Thanks for putting it clearer.







