Closed bortzmeyer closed 1 year ago
That's very surprising behaviour. Thanks for the report. I've added a question in Elixir Forum in the hope someone can given me some suggestions as to what is triggering recompilation in mix run
that is not triggered with mix compile
or iex -S mix
.
The response from ericmj is a clear explanation:
mix run is the same as iex -S mix and they call mix compile so the compilation of your project code they do will be the same.
But when you pass a file to mix run it will evaluate that file, essentially compiling it without storing any compilation artifacts. You shouldn’t pass files from lib/ to mix run since that will compile the file twice, which is why you get the “redefining module” warnings.
You should only pass script files (.exs) to mix run.
OK, it now works with a script (.exs
), not under lib/
, and calling the various modules. Thanks, I understand better how mix works.
Glad that's cleared up the issue. Not sure what your use case is, doing mix run lib/.....exs
isn't that common. If there's anything you need clarification on feel free to start a GitHub discussion and I'm happy to help.
Apparently, each time, I
mix run
, everything is recompiled (with the time it takes) eve,n if I changed nothing in the source code.mix.exs
:lib/test_cldr.ex
:mix run lib/test_cldr.ex
always recompile (with a lot of warnings, see #199):