iex crashing when trying to name a shell, with error "shutdown,{failed_to_start_child,'Elixir.Livebook.EPMD'"...

Hi all,
I’m using Fedora 40, Erlang/OTP 26, and Elixir 1.16.2.

I’m trying to start a named shell, as per IEx Remote Shells documentation, using:

$ iex --sname foo --cookie bar -S mix

However, this command crashes with what I think is the “relevant” error: “shutdown,{failed_to_start_child,‘Elixir.Livebook.EPMD’”… (Not completely sure this is the relevant error, please see below for the complete error message).

If I run either of the following commands, the iex session starts OK, it is only when I include -sname that the crash occurs.

$ iex -S mix
$ iex --cookie bar -S mix

Any idea of what might be the problem?
Thanks for your help!!

I’m a new user, so I am not allowed yet to submit images. So here’s a copy of the error:

2024-08-08 23:56:07.157605 supervisor_report   
    supervisor: {local,net_sup}
    errorContext: start_error
    reason: {'EXIT',{undef,[{'Elixir.Livebook.EPMD',start_link,[],[]},{supervisor,do_start_child_i,3,[{file,"supervisor.erl"},{line,420}]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,406}]},{supervisor,'-start_children/2-fun-0-',3,[{file,"supervisor.erl"},{line,390}]},{supervisor,children_map,4,[{file,"supervisor.erl"},{line,1258}]},{supervisor,init_children,2,[{file,"supervisor.erl"},{line,350}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,980}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,935}]}]}}
    offender: [{pid,undefined},{id,'Elixir.Livebook.EPMD'},{mfargs,{'Elixir.Livebook.EPMD',start_link,[]}},{restart_type,permanent},{significant,false},{shutdown,2000},{child_type,worker}]
=SUPERVISOR REPORT==== 8-Aug-2024::23:56:07.157645 ===
    supervisor: {local,kernel_sup}
    errorContext: start_error
    reason: {shutdown,
                {failed_to_start_child,'Elixir.Livebook.EPMD',
                    {'EXIT',
                        {undef,
                            [{'Elixir.Livebook.EPMD',start_link,[],[]},
                             {supervisor,do_start_child_i,3,
                                 [{file,"supervisor.erl"},{line,420}]},
                             {supervisor,do_start_child,2,
                                 [{file,"supervisor.erl"},{line,406}]},
                             {supervisor,'-start_children/2-fun-0-',3,
                                 [{file,"supervisor.erl"},{line,390}]},
                             {supervisor,children_map,4,
                                 [{file,"supervisor.erl"},{line,1258}]},
                             {supervisor,init_children,2,
                                 [{file,"supervisor.erl"},{line,350}]},
                             {gen_server,init_it,2,
                                 [{file,"gen_server.erl"},{line,980}]},
                             {gen_server,init_it,6,
                                 [{file,"gen_server.erl"},{line,935}]}]}}}}
    offender: [{pid,undefined},
               {id,net_sup},
               {mfargs,{erl_distribution,start_link,[]}},
               {restart_type,permanent},
               {significant,false},
               {shutdown,infinity},
               {child_type,supervisor}]


2024-08-08 23:56:07.158724 Error in process ~p with exit value:~n~p~n
        <0.63.0>
        {badarg,[{erlang,send,[code_server,{code_call,<0.63.0>,{load_module,#Ref<0.1040511193.3284008961.3809>,logger_formatter,"/usr/lib64/erlang/lib/kernel-9.2.4.1/ebin/logger_formatter.beam",false,#Ref<0.1040511193.3283877889.3808>}}],[{error_info,#{module=>erl_erts_errors}}]},{code_server,call,1,[{file,"code_server.erl"},{line,156}]},{error_handler,undefined_function,3,[{file,"error_handler.erl"},{line,40}]},{logger_simple_h,'-do_log/2-fun-0-',1,[{file,"logger_simple_h.erl"},{line,154}]}]}
2024-08-08 23:56:07.158853 crash_report        
    initial_call: {application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}
    pid: <0.46.0>
    registered_name: []
    error_info: {exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,'Elixir.Livebook.EPMD',{'EXIT',{undef,[{'Elixir.Livebook.EPMD',start_link,[],[]},{supervisor,do_start_child_i,3,[{file,"supervisor.erl"},{line,420}]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,406}]},{supervisor,'-start_children/2-fun-0-',3,[{file,"supervisor.erl"},{line,390}]},{supervisor,children_map,4,[{file,"supervisor.erl"},{line,1258}]},{supervisor,init_children,2,[{file,"supervisor.erl"},{line,350}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,980}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,935}]}]}}}}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,142}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}
    ancestors: [<0.45.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.47.0>,normal}]
    links: [<0.45.0>,<0.44.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 987
    stack_size: 28
    reductions: 156
2024-08-08 23:56:07.159792 std_info            
    application: kernel
    exited: {{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,'Elixir.Livebook.EPMD',{'EXIT',{undef,[{'Elixir.Livebook.EPMD',start_link,[],[]},{supervisor,do_start_child_i,3,[{file,"supervisor.erl"},{line,420}]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,406}]},{supervisor,'-start_children/2-fun-0-',3,[{file,"supervisor.erl"},{line,390}]},{supervisor,children_map,4,[{file,"supervisor.erl"},{line,1258}]},{supervisor,init_children,2,[{file,"supervisor.erl"},{line,350}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,980}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,935}]}]}}}}}},{kernel,start,[normal,[]]}}
    type: permanent
Kernel pid terminated (application_controller) ("{application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,'Elixir.Livebook.EPMD',{'EXIT',{undef,[{'Elixir.Livebook.EPMD',start_link,[],[]},{supervisor,do_start_child_i,3,[{file,\"supervisor.erl\"},{line,420}]},{supervisor,do_start_child,2,[{file,\"supervisor.erl\"},{line,406}]},{supervisor,'-start_children/2-fun-0-',3,[{file,\"supervisor.erl\"},{line,390}]},{supervisor,children_map,4,[{file,\"supervisor.erl\"},{line,1258}]},{supervisor,init_children,2,[{file,\"supervisor.erl\"},{line,350}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,980}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,935}]}]}}}}}},{kernel,start,[normal,[]]}}}")
1 Like

I have a similar error. Does anyone have an idea as to what is the culprit?

A bit strange that it points to Livebook related stuff.

P.S. I have Livebook installed, but it’s working fine.

P.P.S. I use asdf.

Okay, I found something interesting.

When I first started livebook I got this message:
ERROR!!! [Livebook] You must set the environment variable ELIXIR_ERL_OPTIONS=“-epmd_module Elixir.Livebook.EPMD” before the command (and exclusively before the command)

So I put ELIXIR_ERL_OPTIONS into my .bashrc file and the livebook works. But iex --sname one doesn’t work. When I remove this variable from .bashrc iex node sessions works fine.

I ran into a similar error when I was testing my production release locally:

SECRET_KEY_BASE=mix phx.gen.secret _build/prod/rel/example/bin/server
=SUPERVISOR REPORT==== 6-Mar-2025::07:22:10.311978 ===
supervisor: {local,net_sup}
errorContext: start_error
reason: {‘EXIT’,
{undef,
[{‘Elixir.Livebook.EPMD’,start_link,,},
{supervisor,do_start_child_i,3,
[{file,“supervisor.erl”},{line,420}]},
{supervisor,do_start_child,2,
[{file,“supervisor.erl”},{line,406}]},
{supervisor,‘-start_children/2-fun-0-’,3,
[{file,“supervisor.erl”},{line,390}]},
{supervisor,children_map,4,
[{file,“supervisor.erl”},{line,1258}]},
{supervisor,init_children,2,
[{file,“supervisor.erl”},{line,350}]},

Claude 3.7 Sonnet in the Windsurf IDE helped me diagnose it after I insisted that we look into the root cause of the issue instead of applying workarounds:

Now we’ve found the root cause! There’s a line in your .zshrc file that’s setting ELIXIR_ERL_OPTIONS to use Livebook’s EPMD module:

bash

CopyInsert in Terminal

export ELIXIR_ERL_OPTIONS="-epmd_module Elixir.Livebook.EPMD"

This setting affects all Elixir processes started from your shell, including your Phoenix application builds and releases. This is typically added when you install Livebook to prevent port conflicts between different EPMD instances, but it’s affecting all your Elixir applications.

To fix the issue, you have a few options:

  1. Remove or comment out the line in your .zshrc - This will stop using Livebook’s EPMD module for all Elixir applications:
# Comment out the line
# export ELIXIR_ERL_OPTIONS="-epmd_module Elixir.Livebook.EPMD"
  1. Modify your .zshrc to only set this variable when running Livebook - Create a wrapper function or alias for Livebook:
# Remove the global export
# export ELIXIR_ERL_OPTIONS="-epmd_module >Elixir.Livebook.EPMD"

# Add a function to run Livebook with the special EPMD module
run_livebook() {
  ELIXIR_ERL_OPTIONS="-epmd_module Elixir.Livebook.EPMD" livebook $@
}
alias livebook=run_livebook
  1. Keep using the workaround with
    RELEASE_DISTRIBUTION=none
    for your Phoenix applications as needed.