Check for flyctl in default install locations (#2722)

This commit is contained in:
Jonatan Kłosko 2024-07-24 19:32:55 +02:00 committed by GitHub
parent 5686771646
commit 303f78a418
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 3 deletions

View file

@ -302,7 +302,7 @@ defmodule Livebook.Runtime.Fly do
end
defp find_fly_executable() do
if path = System.find_executable("flyctl") do
if path = System.find_executable("flyctl") || default_flyctl_path() do
{:ok, path}
else
{:error,
@ -311,6 +311,20 @@ defmodule Livebook.Runtime.Fly do
end
end
defp default_flyctl_path() do
# Checks the default locations where flyctl gets installed using
# the official instructions
home = System.user_home()
paths = [
"/opt/homebrew/bin/flyctl",
home && Path.join(home, ".fly/bin/flyctl")
]
Enum.find(paths, fn path -> path && File.regular?(path) end)
end
defp fetch_runtime_info(child_node) do
# Note: it is Livebook that starts the runtime node, so we know
# that the node runs Livebook release of the exact same version

View file

@ -1,4 +1,4 @@
File.cd!(System.fetch_env!("HOME"))
File.cd!(System.user_home!())
flame_parent = System.fetch_env!("FLAME_PARENT") |> Base.decode64!() |> :erlang.binary_to_term()

View file

@ -1,4 +1,4 @@
File.cd!(System.fetch_env!("HOME"))
File.cd!(System.user_home!())
%{
node_base: node_base,