Skip to content

Commit

Permalink
Fix attached runtime to not rely on Mix
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Jan 7, 2025
1 parent 0438c5f commit feefc4f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/livebook/runtime/erl_dist/runtime_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,21 @@ 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 && install_project_dir() do
send(state.owner, {:runtime_transient_state, %{mix_install_project_dir: dir}})
%{state | mix_install_project_dir: dir}
else
state
end
end

defp install_project_dir() do
# Make sure Mix is loaded (it may not be in case of attached runtime)
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
Expand Down

0 comments on commit feefc4f

Please sign in to comment.