Thanks. I think mix ecto.setup
is now working, I just need to remove the duplicate aliases/0
entry in the app/foo’s mix.exs file.
The only problem now is that I can’t recreate a fresh installation of a working umbrella app with a phoenix app under it. Here’s what I did and the error I encountered:
mix new umbrella --umbrella
cd umbrella/apps
mix new baz
mix phx.new foo #fetch and install dependencies [n]
cd foo
mix phauxth.new --confirm --remember
cd ../../
mix deps.get
iex -S mix phx.server
I did not modify any mix.exs files or add aliases yet. I didn’t create the DB either, I just wanted to get the phoenix server up and running first from the root umbrella directory.
Here’s a snippet of the error during compilation.
Generated phoenix_ecto app
==> baz
Compiling 1 file (.ex)
Generated baz app
==> foo
Compiling 25 files (.ex)
Generated foo app
[error] GenServer Phoenix.CodeReloader.Server terminating
** (RuntimeError) trying to access Mix.Project.app_path for an umbrella project but umbrellas have no app
(mix) lib/mix/project.ex:486: Mix.Project.app_path/1
(phoenix) lib/phoenix/code_reloader/server.ex:28: Phoenix.CodeReloader.Server.handle_call/3
(stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:665: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message (from FooWeb.Endpoint): :check_symlinks
State: false
Client FooWeb.Endpoint is alive
(stdlib) gen.erl:169: :gen.do_call/4
(elixir) lib/gen_server.ex:831: GenServer.call/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:62: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:294: :supervisor.init/1
(stdlib) gen_server.erl:365: :gen_server.init_it/2
(stdlib) gen_server.erl:333: :gen_server.init_it/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
[info] Application foo exited: Foo.Application.start(:normal, []) returned an error: shutdown: failed to start child: FooWeb.Endpoint
** (EXIT) exited in: GenServer.call(Phoenix.CodeReloader.Server, :check_symlinks, :infinity)
** (EXIT) an exception was raised:
** (RuntimeError) trying to access Mix.Project.app_path for an umbrella project but umbrellas have no app
(mix) lib/mix/project.ex:486: Mix.Project.app_path/1
(phoenix) lib/phoenix/code_reloader/server.ex:28: Phoenix.CodeReloader.Server.handle_call/3
(stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:665: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application foo: Foo.Application.start(:normal, []) returned an error: shutdown: failed to start child: FooWeb.Endpoint
** (EXIT) exited in: GenServer.call(Phoenix.CodeReloader.Server, :check_symlinks, :infinity)
** (EXIT) an exception was raised:
** (RuntimeError) trying to access Mix.Project.app_path for an umbrella project but umbrellas have no app
(mix) lib/mix/project.ex:486: Mix.Project.app_path/1
(phoenix) lib/phoenix/code_reloader/server.ex:28: Phoenix.CodeReloader.Server.handle_call/3
(stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:665: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
folder tree
mix.exs
defmodule Umbrella.MixProject do
use Mix.Project
def project do
[
apps_path: "apps",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
defp deps do
[]
end
end
config/config.exs
use Mix.Config
import_config "../apps/*/config/config.exs"
apps/foo/mix.exs
defmodule Foo.Mixfile do
use Mix.Project
def project do
[
app: :foo,
version: "0.0.1",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.6",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
start_permanent: Mix.env == :prod,
aliases: aliases(),
deps: deps()
]
end
def application do
[
mod: {Foo.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp deps do
[
{:phoenix, "~> 1.3.1"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.10"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:phauxth, "~> 1.2"},
{:bcrypt_elixir, "~> 1.0"},
{:bamboo, "~> 0.8"},
{:cowboy, "~> 1.0"}
]
end
defp aliases do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quiet", "ecto.migrate", "test"]
]
end
end