I have an umbrella app and I am trying to add a phoenix app inside of it. However, When I run the mix command to create a phoenix umbrella app, I get an error I don’t understand.
Problem
I have an umbrella app with the following structure:
market_manager
|_apps
|_ app1
|_ app2
I want to add another umbrella app to my apps folder, a phx_test_app.
To do so I am running mix phx.new.web phx_test --live --no-ecto inside of my apps folder. However I get the following error:
λ mix phx.new.web test --no-ecto
** (Mix) Could not find "use Mix.Config" or "import Config" in "c:/Users/palme/Documents/GitHub/market_manager/config/config.exs"
To me this is confusing, as this is contents of the file in question:
import Config
import_config "#{Mix.env()}.exs"
So I definitely have the one thing the error says I am missing.
Questions
Why am I having this error and how can I fix it?
For those of you curious enough, this is the project in question:
Even after updating, it still fails.
I have also deleted my project and cloned it from zero again in hopes it would fix the issue, but alas, I was not that lucky:
λ mix archive.install hex phx_new 1.5.9
Resolving Hex dependencies...
Dependency resolution completed:
New:
phx_new 1.5.9
* Getting phx_new (Hex package)
All dependencies are up to date
Compiling 10 files (.ex)
Generated phx_new app
Generated archive "phx_new-1.5.9.ez" with MIX_ENV=prod
Found existing entry: c:/Users/palme/.mix/archives/phx_new-1.5.9
Are you sure you want to replace it with "phx_new-1.5.9.ez"? [Yn] Y
* creating c:/Users/palme/.mix/archives/phx_new-1.5.9
C:\Users\palme\Documents\GitHub\market_manager\apps (dev -> origin)
λ mix phx.new.web phx_test --live --no-ecto
** (Mix) Could not find "use Mix.Config" or "import Config" in "c:/Users/palme/Documents/GitHub/market_manager/config/config.exs"
$ mix new koko --umbrella
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating apps
* creating config
* creating config/config.exs
Your umbrella project was created successfully.
Inside your project, you will find an apps/ directory
where you can create and host many apps:
cd koko
cd apps
mix new my_app
Commands like "mix compile" and "mix test" when executed
in the umbrella project root will automatically run
for each application in the apps/ directory.
$ cd koko/apps/
$ mix phx.new.web test --no-ecto --live
* creating test/lib/test.ex
* creating test/lib/test/application.ex
* creating test/lib/test/channels/user_socket.ex
* creating test/lib/test/endpoint.ex
* creating test/lib/test/router.ex
* creating test/lib/test/telemetry.ex
* creating test/lib/test/views/error_helpers.ex
* creating test/lib/test/views/error_view.ex
* creating test/mix.exs
* creating test/README.md
* creating test/.gitignore
* creating test/test/test_helper.exs
* creating test/test/support/channel_case.ex
* creating test/test/support/conn_case.ex
* creating test/test/test/views/error_view_test.exs
* creating test/.formatter.exs
* creating test/lib/test/templates/layout/root.html.leex
* creating test/lib/test/templates/layout/app.html.eex
* creating test/lib/test/templates/layout/live.html.leex
* creating test/lib/test/views/layout_view.ex
* creating test/lib/test/live/page_live.ex
* creating test/lib/test/live/page_live.html.leex
* creating test/test/test/views/layout_view_test.exs
* creating test/test/test/live/page_live_test.exs
* creating test/lib/test/gettext.ex
* creating test/priv/gettext/en/LC_MESSAGES/errors.po
* creating test/priv/gettext/errors.pot
* creating test/assets/webpack.config.js
* creating test/assets/.babelrc
* creating test/assets/js/app.js
* creating test/assets/css/app.scss
* creating test/assets/package.json
* creating test/assets/static/favicon.ico
* creating test/assets/css/phoenix.css
* creating test/assets/static/images/phoenix.png
* creating test/assets/static/robots.txt
Fetch and install dependencies? [Yn]
* running mix deps.get
* running mix deps.compile
* running cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
We are almost there! The following steps are missing:
$ cd test
Your web app requires a PubSub server to be running.
The PubSub server is typically defined in a `mix phx.gen.ecto` app.
If you don't plan to define an Ecto app, you must explicitly start
the PubSub in your supervision tree as:
{Phoenix.PubSub, name: Test.PubSub}
Start your Phoenix app with:
$ mix phx.server
You can also run your app inside IEx (Interactive Elixir) as:
$ iex -S mix phx.server
It was the line endings. Should this not be considered a bug?
I believe so, because it should also work for Windows, since Elixir also supports it.
I will create an issue in the mentioned repo with the solution and a fix, and hopefully the creators will have a fix for it and no one else will have to go through the same problem again.
I know most people prefer Linux when coding Elixir (me included) but if we find and report Windows issues like we did here we make Elixir better for everyone!