Skip to content

Warning about configured app in umbrella application #10482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TBK145 opened this issue Nov 4, 2020 · 7 comments
Closed

Warning about configured app in umbrella application #10482

TBK145 opened this issue Nov 4, 2020 · 7 comments

Comments

@TBK145
Copy link
Contributor

TBK145 commented Nov 4, 2020

Environment

Current behavior

We have a umbrella project with several dependencies in the root mix.exs file that are only used for development and CI, for example 'junit_formatter'. We configure this application in our root config file as well. When running mix test (or mix run with MIX_ENV=test) we get this warning:

You have configured application :junit_formatter in your configuration file,
but the application is not available.

This usually means one of:

  1. You have not added the application as a dependency in a mix.exs file.

  2. You are configuring an application that does not really exist.

Please ensure :junit_formatter exists or remove the configuration.

When I move the dependency from the root mix.exs to one of the umbrella applications, the warning disappears.

Expected behavior

Not seeing a warning, because the application is added as depency in the root mixfile.

@josevalim
Copy link
Member

Dependencies in the root are not available in child applications, therefore the warning is correct. You need to explicitly list the dependencies in all projects that need them.

If you find this too verbose, you can create a file in your umbrella root called shared_project.exs with this:

defmodule SharedProject do
  def deps, do: [...]
end

And then in each mix.exs you can require this file and use the shared helpers. Another option is to create a project in the umbrelled called dev_helpers, which has these dependencies, and other conveniences you woudl like to share.

@TBK145
Copy link
Contributor Author

TBK145 commented Nov 5, 2020

I understand that these applications listed in the root mixfile can't be used in the child applications, but that's not the case here. The only reference to this dependency is in our root config for ex_unit:

config :ex_unit,
  assert_receive_timeout: 1000,
  formatters: [JUnitFormatter, ExUnit.CLIFormatter]

@josevalim
Copy link
Member

Can you please provide a minimal application that reproduces the error then? Thank you.

@TBK145
Copy link
Contributor Author

TBK145 commented Nov 5, 2020

I created a very small application here: https://github.com/TBK145/config_warning.

The warning appears when running mix test, and when running MIX_ENV=test mix run it will display the warning for :ex_unit as well.

@josevalim
Copy link
Member

Thanks @TBK145! The warnings are correct:

  1. As I first mentioned, a dependency at the root is not available in children, so you need to make sure to include junit_formatter on all children

  2. For ex_unit we have the same issue, the application ex_unit is only loaded for mix test but not mix run. Move the config to test/test_helper.exs files instead. You can also have a shread test_helper as explained above.

@TBK145
Copy link
Contributor Author

TBK145 commented Nov 5, 2020

Thanks, I guess I don't fully understand how junit_formatter is called by the child application, as I was under the impression that it was only used by ex_unit.
Is it then that ex_unit is started by every application separately?

@josevalim
Copy link
Member

Your umbrella apps and all child apps load the same config file. The issue is that you are configuring an application that does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants