I have a fresh umbrella app and I am trying to create a Phoenix app inside it. However, even though I can create the Phoenix app inside the umbrella, I cannot build it successfully.
I am creating a phoenix app inside a fresh umbrella project like this:
mix new test_app --umbrella
cd apps
mix phx.new web_interface --no-dashboard --no-ecto --no-gettext --no-mailer --live
These commands run fine. However when I try to setup the app, something breaks:
cd web_interface
mix setup
returns:08:14:50.318 [warning] tailwind version is not configured. Please set it in your config files:
config :tailwind, :version, "3.2.4"
Browserslist: caniuse-lite is outdated. Please run: npx update-browserslist-db@latest Why you should do it regularly: https://github.com/browserslist/update-db#readme
Rebuilding...
To me, this is odd. Everything is fresh new, so I was really not expecting any warning. But it gets worse. Once rebuilding is done, I get an actual error:
Done in 200ms.
08:14:52.146 [warning] esbuild version is not configured. Please set it in your config files:
config :esbuild, :version, "0.16.4"
** (RuntimeError) no arguments passed to esbuild (esbuild 0.7.0) lib/esbuild.ex:170: Esbuild.run/2 (esbuild 0.7.0) lib/mix/tasks/esbuild.ex:49: Mix.Tasks.Esbuild.install_and_run/1 (mix 1.14.1) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4 (mix 1.14.1) lib/mix/task.ex:479: Mix.Task.run_alias/6 (mix 1.14.1) lib/mix/cli.ex:84: Mix.CLI.run_task/2
At first I thought this was happening because I had something outdated in my machine. So I did some updates:
mix local.hex
mix archive.install hex phx_new
However, this did not fix the issue.
I am running on Windows.
--live
flag became a default in Phoenix 1.6. Is this still case for 1.7? (Meaning all apps are live now, by default?)The issue here was that I was using an incorrect command when creating the Phoenix app. I was using mix phx.new
instead of mix phx.new.web
.
To me, this is rather confusing, as from the documentation/tutorials (https://elixir-lang.org/getting-started/mix-otp/dependencies-and-umbrella-projects.html#umbrella-projects) we have this quote:
(...) First of all, since we generated this project inside
kv_umbrella/apps
, Mix automatically detected the umbrella structure (...)
Which states that when creating an app inside an umbrella project, Mix does have the capacity to detect it and act accordingly.
This does not hold true for Phoenix apps. For reasons beyond my understanding, Phoenix apps do not know their context and thus the user needs to tell mix that the new app will be inside an umbrella project.
This is confusing to me. Sometimes mix
is smart enough to know, other times, it isn't. I don't know which times it knows and which times it doesn't.
So, to conclude, given the original questions:
mix phx.new.web
. It is unclear when Mix is able to detect umbrella apps and when its not.--live
flag is now default and not needed.