Running mix phx.server from the root of an umbrella should start serving Phoenix endpoints from child applications.
Running mix phx.server from an umbrella root with one child app (otp_app: :app, mod: App/AppWeb, path: apps/app) causes an error.
Repro:
mix new test_umbrella --umbrellacd test_umbrella/appsmix phx.new appSet dependencies in test_umbrella/apps/app/mix.exs:
...
{:phoenix, github: "phoenixframework/phoenix", override: true},
{:plug, "~> 1.5.0-rc2", override: true},
...
From the root of the umbrella, test_umbrella, running mix phx.server throws:
[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 AppWeb.Endpoint): :check_symlinks
State: false
Client AppWeb.Endpoint is alive
(stdlib) gen.erl:169: :gen.do_call/4
(elixir) lib/gen_server.ex:827: GenServer.call/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:36: 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 app exited: App.Application.start(:normal, []) returned an error: shutdown: failed to start child: AppWeb.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 app: App.Application.start(:normal, []) returned an error: shutdown: failed to start child: AppWeb.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
Looks like this issue was introduced in 3d70a05 (relevant call to Mix.Project.app_path/1).
Thanks! Let me know if I can help with more info or a PR. Not sure I understand the Mix project structure well enough yet to fix on my own, but happy to help.
Thanks @josevalim! 鉂わ笍
I'm not sure if I've done something wrong, but it seems that I've updated to Phoenix 1.3.1 tonight, and that this issue's fix wasn't included in 1.3.1.
When adding a dependency to my project tonight (EctoJob), I found that it needed a newer version Ecto, so I appended ~ to my mix.lock filename and got the dependencies again. My tests then failed, but this was remedied by removing the _build directory. However, when running mix phx.server I get (RuntimeError) trying to access Mix.Project.app_path for an umbrella project but umbrellas have no app, as per this issue's description.
When finding this issue and looking into the commits involved, I realised that Phoenix 1.3.1 had been released a few hours ago. However, it seems that the fix isn't 1.3.1, despite having been made 9 days ago.
deps/phoenix/lib/phoenix/code_reloader/server.ex:27 in my project:
if not checked? and Code.ensure_loaded?(Mix.Project) do
deps/phoenix/mix.exs in my project:
defmodule Phoenix.Mixfile do
use Mix.Project
@version "1.3.1"
# TODO v1.4: Update to elixir 1.4 + new application inference
Also, the changlog entry for 1.3.1 has a future date of 2018-04-02. Is 1.3.1 supposed to be released yet? I have ~> 1.3.0 in my umbrella app's child apps' deps and received 1.3.1. If I use 1.3.0, mix phx.server works okay.
@chrismccord, apologies if this is something wrong my end, and thanks for Phoenix!
Unfortunately this commit was not backported at the time. I have backported it now so it makes to the next release.
Thanks very much, @josevalim. Am I right in thinking that everyone running the server from the root of an umbrella app in 1.3.1 will get the error? If so, I suppose another release will be available very soon?
Yes, you are right about it. @chrismccord would be the best to tell about a
release. Although we should probably wait a week in case there are any
Jos茅 Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D
I thought I backported that fix, but it will need to wait until next week sometime. Thanks!
Is there a work-around for this?
Edit: work around is to run phx.server from the application directory. So something like:
cd apps/my_phoenix_app
mix phx.server
or use the v1.3 branch. :)
Note: one downside to running phx.server from the specific application instead of the umbrella root is that it breaks code reloading. So now you will need to restart the phoenix server if any of the other umbrella apps are changed.
Most helpful comment
Is there a work-around for this?
Edit: work around is to run
phx.serverfrom the application directory. So something like: