diff --git a/config/dev.exs b/config/dev.exs index b88a4221a..7ee06c0c4 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -71,3 +71,5 @@ config :phoenix, :plug_init_mode, :runtime # Disable authentication mode during dev config :livebook, :authentication_mode, :disabled + +config :livebook, :data_path, Path.expand("tmp/livebook_data/dev") diff --git a/config/test.exs b/config/test.exs index 384cc55c9..05d6b225d 100644 --- a/config/test.exs +++ b/config/test.exs @@ -14,6 +14,8 @@ config :logger, level: :warn # Disable authentication mode during test config :livebook, :authentication_mode, :disabled +config :livebook, :data_path, Path.expand("tmp/livebook_data/test") + # Use the embedded runtime in tests by default, so they # are cheaper to run. Other runtimes can be tested by starting # and setting them explicitly diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index aec03e107..939d88069 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -6,7 +6,8 @@ defmodule Livebook.Application do use Application def start(_type, _args) do - ensure_local_filesystem!() + ensure_directories!() + set_local_filesystem!() ensure_distribution!() validate_hostname_resolution!() set_cookie() @@ -55,7 +56,12 @@ defmodule Livebook.Application do :ok end - defp ensure_local_filesystem!() do + defp ensure_directories!() do + File.mkdir_p!(Livebook.Config.home()) + File.mkdir_p!(Livebook.Config.data_path()) + end + + defp set_local_filesystem!() do home = Livebook.Config.home() |> Livebook.FileSystem.Utils.ensure_dir_path()