Error trying to invoke remote on running mix release

I have a mix release running on a production server and am trying to connect iex to the running app using bin/app remote but I get the following error:

$ bin/app remote
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.15.6) - press Ctrl+C to exit (type h() ENTER for help)
*** ERROR: Shell process terminated! (^G to start new job) ***

14:57:10.987 [error] Process #PID<9920.2433.0> on node :app@host raised an exception
** (ArgumentError) errors were found at the given arguments:

  * 2nd argument: not a pid

    :erlang.monitor(:process, {:error, {%RuntimeError{message: "could not find the user home, please set the HOME environment variable"}, [{System, :user_home!, 0, [file: ~c"lib/system.ex", line: 375, error_info: %{module: Exception}]}, {Path, :resolve_home, 1, [file: ~c"lib/path.ex", line: 716]}, {Path, :expand, 1, [file: ~c"lib/path.ex", line: 166]}, {Enum, :"-map/2-lists^map/1-1-", 2, [file: ~c"lib/enum.ex", line: 1693]}, {Enum, :"-map/2-lists^map/1-1-", 2, [file: ~c"lib/enum.ex", line: 1693]}, {IEx.Evaluator, :load_dot_iex, 2, [file: ~c"lib/iex/evaluator.ex", line: 256]}, {IEx.Evaluator, :init, 5, [file: ~c"lib/iex/evaluator.ex", line: 28]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 240]}]}})
    lib/iex/server.ex:89: IEx.Server.run_without_registration/3

Anyone else seen this?

Yes, the boot-script requires you to have the HOME environment variable to be set. Try with HOME=. bin/app remote

Yeah, tried that but still get the same error.

I have subsequently managed to attach a remote iex shell to it using iex --sname my_remote --cookie COOKIE then Node.connect( ... ).

Would the fact that the app is running as a system process have an impact I wonder.

I have the HOME environment variable set in my systemd unit file too, don’t know how you start your app.

1 Like