TIL about ELIXIR_CLI_DRY_RUN for elixir and iex
⭐️ a blog post
While I’ve been working on deploying some elixir releases I’ve been trying to
understand how the flags I’m setting end up being seen by erlang. Well, it turns out
elixir
has an ENV var for this named ELIXIR_CLI_DRY_RUN.
Here is an example:
$ ELIXIR_CLI_DRY_RUN=1 iex
erl -pa /usr/local/Cellar/elixir/1.11.2/bin/../lib/eex/ebin \
/usr/local/Cellar/elixir/1.11.2/bin/../lib/elixir/ebin \
/usr/local/Cellar/elixir/1.11.2/bin/../lib/ex_unit/ebin \
/usr/local/Cellar/elixir/1.11.2/bin/../lib/iex/ebin \
/usr/local/Cellar/elixir/1.11.2/bin/../lib/logger/ebin \
/usr/local/Cellar/elixir/1.11.2/bin/../lib/mix/ebin \
-noshell \
-user Elixir.IEx.CLI \
-extra --no-halt +iex
You can see a lot of interesting info here:
-
elixiroriexare always just runningerlin the end -
-pais to prepend a module load path and elixir makes sure all it’s modules are accessible at boot -
-noshellmeans to, uh, not start the erlang shell, since iex is going to boot up it’s own shell in it’sstartfunction with:user_drv(find it in the erl docs) -
-useris the first module erlang will callstartof after boot, in this instance it’sElixir.IEx.CLI -
-extrameans “erlwon’t look at these, but they are available with:init.get_plain_arguments()which elixir does a few times -
--no-halttells elixir not to auto-exit after boot, so iex can setup it’s shell and accept input -
+iexis a special flag elixir looks for while starting up it’s CLI (which is also called byIEx.start)
I found this super interesting and it helped me learn a lot about how erlang boots up, how modules are loaded, etc.