Fix attached runtime to not rely on Mix

This commit is contained in:
Jonatan Kłosko 2025-01-07 13:51:58 +07:00
parent 0438c5fbe2
commit 912ec796da

View file

@ -855,7 +855,7 @@ defmodule Livebook.Runtime.ErlDist.RuntimeServer do
# We propagate Mix.install/2 project dir in the transient state,
# so that future runtimes can set it as the starting point for
# Mix.install/2
if dir = state.mix_install_project_dir == nil && Mix.install_project_dir() do
if dir = state.mix_install_project_dir == nil && mix_install_project_dir() do
send(state.owner, {:runtime_transient_state, %{mix_install_project_dir: dir}})
%{state | mix_install_project_dir: dir}
else
@ -863,6 +863,13 @@ defmodule Livebook.Runtime.ErlDist.RuntimeServer do
end
end
defp mix_install_project_dir() do
# Make sure Mix is loaded (for attached runtime it may not)
if Code.ensure_loaded?(Mix) do
Mix.install_project_dir()
end
end
defp scan_binding_async(_ref, %{scan_binding: nil} = info, _state), do: info
# We wait for the current scanning to finish, this way we avoid