diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index b5f70d0de3ac..d57efdf70b84 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -39,16 +39,39 @@ defmodule Livebook.Application do defp ensure_distribution!() do unless Node.alive?() do - System.cmd("epmd", ["-daemon"]) + case System.cmd("epmd", ["-daemon"]) do + {_, 0} -> + :ok + + _ -> + abort!(""" + could not start epmd (Erlang Port Mapper Driver). Livebook uses epmd to \ + talk to different runtimes. You may have to start epmd explicitly by calling: + + epmd -daemon + + Or by calling: + + elixir --sname test -e "IO.puts node()" + + Then you can try booting Livebook again + """) + end + {type, name} = get_node_type_and_name() case Node.start(name, type) do {:ok, _} -> :ok - {:error, _} -> raise "failed to start distributed node" + {:error, reason} -> abort!("could not start distributed node: #{inspect(reason)}") end end end + defp abort!(message) do + IO.puts("\nERROR!!! [Livebook] " <> message) + System.halt(1) + end + defp get_node_type_and_name() do Application.get_env(:livebook, :node) || {:shortnames, random_short_name()} end diff --git a/lib/livebook/runtime/elixir_standalone.ex b/lib/livebook/runtime/elixir_standalone.ex index d09ecc7abc10..ad7707e3029d 100644 --- a/lib/livebook/runtime/elixir_standalone.ex +++ b/lib/livebook/runtime/elixir_standalone.ex @@ -55,7 +55,9 @@ defmodule Livebook.Runtime.ElixirStandalone do defp start_elixir_node(elixir_path, node_name, eval) do # Here we create a port to start the system process in a non-blocking way. Port.open({:spawn_executable, elixir_path}, [ + :binary, :nouse_stdio, + :hide, args: elixir_flags(node_name) ++ ["--eval", eval] ]) end diff --git a/lib/livebook/runtime/mix_standalone.ex b/lib/livebook/runtime/mix_standalone.ex index 2b8e51de7acf..4fdeb3229fb5 100644 --- a/lib/livebook/runtime/mix_standalone.ex +++ b/lib/livebook/runtime/mix_standalone.ex @@ -91,6 +91,7 @@ defmodule Livebook.Runtime.MixStandalone do Port.open({:spawn_executable, elixir_path}, [ :binary, :stderr_to_stdout, + :hide, args: elixir_flags(node_name) ++ ["-S", "mix", "run", "--eval", eval], cd: project_path ])