Improve error message when attaching to a remote node with different ERTS version (#511)

* Improve error message when attaching to a remote node with different ERTS version

* Make the error more specific

* Update lib/livebook/runtime/erl_dist.ex

Co-authored-by: José Valim <jose.valim@dashbit.co>

* Update lib/livebook/runtime/erl_dist.ex

* Update lib/livebook/runtime/erl_dist.ex

* Update lib/livebook/runtime/erl_dist.ex

Co-authored-by: José Valim <jose.valim@dashbit.co>
This commit is contained in:
Jonatan Kłosko 2021-08-22 00:52:19 +02:00 committed by GitHub
parent 87b6f6160e
commit ab30f84548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,7 +57,23 @@ defmodule Livebook.Runtime.ErlDist do
defp load_required_modules(node) do
for module <- @required_modules do
{_module, binary, filename} = :code.get_object_code(module)
{:module, _} = :rpc.call(node, :code, :load_binary, [module, filename, binary])
case :rpc.call(node, :code, :load_binary, [module, filename, binary]) do
{:module, _} ->
:ok
{:error, reason} ->
local_otp = :erlang.system_info(:otp_release)
remote_otp = :rpc.call(node, :erlang, :system_info, [:otp_release])
if local_otp != remote_otp do
raise RuntimeError,
"failed to load #{inspect(module)} module into the remote node, potentially due to Erlang/OTP version mismatch, reason: #{inspect(reason)} (local #{local_otp} != remote #{remote_otp})"
else
raise RuntimeError,
"failed to load #{inspect(module)} module into the remote node, reason: #{inspect(reason)}"
end
end
end
end