Global Umbrella Dependencies

I want to add the :logger_file_backend for dev only. I thought it would be cool to add it to the root mix.exs file, configure it in the root config/dev.exs file and have all my apps log to the dev.log in development. It works with iex -S mix from the root, but cding into an app and running iex -S mix raises because it can’t find the dep.

Obviously I know have to add the :logger_file_backend dep to all my umbrella apps. I don’t really understand why though… I’m a doing something wrong? Can I not just declare it once in the global mix.exs?

1 Like

An app within an umbrella is just like a normal app except that some mix project settings are different (build_path, config_path, deps_path, lockfile), there’s no extra magic there. I think it would be confusing if child apps automatically get dependencies/tasks from the umbrella root (which usually does not contain any code anyway). It would also make it harder to potentially extract a child app into a separate project because of these implicit assumptions.

If you find yourself adding the same dependencies over and over again and it bothers you (for me it’s not a big deal yet) you can always create some common app with the shared dependencies and let other apps depend on that common app.

5 Likes