diff --git a/lib/livebook/runtime/erl_dist/runtime_server.ex b/lib/livebook/runtime/erl_dist/runtime_server.ex index 05dff5c0a01..2b40c3c701d 100644 --- a/lib/livebook/runtime/erl_dist/runtime_server.ex +++ b/lib/livebook/runtime/erl_dist/runtime_server.ex @@ -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