I run Phoenix (Rails-like web framework for Elixir) like so:

elixir --name [email protected] --cookie bar --erl \"-elixir ansi_enabled true\" -S mix phx.server

… then connect IEx (the Elixir REPL) using:

random=$(head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9 | head -c 8)
iex --name "iex-$random" --remsh [email protected] --cookie bar

… and connect Livebook (Jupyter for Elixir) using:

export LIVEBOOK_DEFAULT_RUNTIME=attached:[email protected]:bar
livebook server @home

The server node (Erlang VM instance) has the name [email protected], and IEx nodes have names like [email protected].

Now I can recompile code in the server node (which is the same node that Livebook is attached to) by entering recompile in IEx. Sometimes it looks like Phoenix.CodeReloader even reloads the code automatically, so recompile evaluates to :noop, which is nice! This means I can use Livebook to test out server functions as I iterate on them.

I tried running Livebook in its own node for a bit and including server code using:

    {:foo, path: "..."}
  config_path: ".../config.exs"

This also works alright, but it’s nice to be connected to the same server node because you can e.g. look at the state of GenServer processes with :sys.get_state.