How to get iex -S mix equivalent with a mix release

My app is currently crashing during mix release start with a very odd ecto sql exception, and I would like to verify that eg. the Application env is set correctly, that all debug is turned on, and then maybe manually pull up the app. During local developments it’s possible to get an iex with all the correct dependencies but without booting their otp apps using iex -S mix. With mix release I only seem to be able to get an iex after booting the app as well (start_iex and daemon_iex). How can I get the same effect with an Elixir 1.10 release? Can coerce ‘eval’ to give me an IEx shell?

You can create an alternative boot script that loads but does not start some applications.

  1. Duplicate releases/0.1.0/start.script to releases/0.1.0/load.script
  2. Remove one or more {apply,{application,start_boot,[app_name,permanent]}} lines, as necessary
  3. Compile the boot script, e.g. elixir -e ":systools.script2boot('releases/0.1.0/load')"
  4. Run the release with the alternative boot script, e.g. RELEASE_BOOT_SCRIPT=load ./bin/app_name start_iex

Or you can start with the built-in boot script start_clean and then manually start specific dependencies you need using Application.ensure_all_started(:some_dependency):

$ RELEASE_BOOT_SCRIPT=start_clean ./bin/app_name start_iex
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(app_name@localhost)1> Application.ensure_all_started(:ssl)
{:ok, [:crypto, :asn1, :public_key, :ssl]}
iex(app_name@localhost)2>
4 Likes