[Duplicate of post to google group, before I realized that group was deprecated]
Presume I am creating a new application with these commands:
mix new my_app
cd my_app
I then use the editor of my choice to put some functions into lib/my_app.ex
If I want to test those functions in iex, am I best off doing this:
iex -S mix
or
cd lib
iex
If I do the former, then when I make changes to the source file, I have to do this in iex:
c("lib/my_app.ex")
whereas the second version needs only
c("my_app.ex")
Both of these seem to work equally well. Which is the correct or preferred way, if either? Or is there a “best practices” method that I am totally missing here?
I recommend running the project with iex -S mix and then, if you want to recompile a single module, use the r/1 function, which takes the module name, rather than a file path.
This is exactly the approach that I am using as well, and it works great for me!
I often have two terminal tabs, one where I run IEx and recompile modules when they change to manually test things, and one where I run mix test as well as version control commands to store my changes.
IIRC correctly there is even a package, that does recompile and reload your changed modules. remix and eye_drops might be able to get configured/hacked that way.