From 990949e3ad8839d6dae776732110b780d3001b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 28 Sep 2023 10:52:21 +0200 Subject: [PATCH] Better long name hints (#2234) --- lib/livebook/application.ex | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index 2fb4e5ccb..58c678a16 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -150,6 +150,41 @@ defmodule Livebook.Application do :ok else _ -> + hint = + cond do + is_nil(System.get_env("LIVEBOOK_DESKTOP")) -> + """ + * If you are using Livebook's CLI or from source, consider using longnames: + + livebook server --name livebook@127.0.0.1 + elixir --name livebook@127.0.0.1 -S mix phx.server + """ + + match?({:win32, _}, :os.type()) -> + path = + Path.join( + System.get_env("USERPROFILE", "%USERPROFILE%"), + ".livebookdesktop.bat" + ) + + """ + * Configure your Livebook Desktop to use long names by creating a file at #{path} with: + + set LIVEBOOK_DISTRIBUTION=name + set LIVEBOOK_NODE=livebook@127.0.0.1 + """ + + true -> + path = Path.join(System.get_env("HOME", "~"), ".livebookdesktop.sh") + + """ + * Configure your Livebook Desktop to use long names by creating a file at #{path} with: + + export LIVEBOOK_DISTRIBUTION=name + export LIVEBOOK_NODE=livebook@127.0.0.1 + """ + end + Livebook.Config.abort!(""" Your hostname \"#{hostname}\" does not resolve to a loopback address (127.0.0.0/8), \ which indicates something wrong in your OS configuration, or EPMD is not running. @@ -159,10 +194,7 @@ defmodule Livebook.Application do * Consult our Installation FAQ: https://github.com/livebook-dev/livebook/wiki/Installation-FAQ - * If you are using Livebook's CLI or from source, consider using longnames: - - livebook server --name livebook@127.0.0.1 - elixir --name livebook@127.0.0.1 -S mix phx.server + #{hint}\ * If the issue persists, please file a bug report