hauleth

hauleth

Currently default Umbrella applications contains

import_config "apps/*/config/config.exs

In their root configuration file. My general question is why though? IMHO it provides only confusion and can lead to ugly bugs when order in which the “nested” configuration files will be imported will change (I haven’t seen any order guarantees in documentation of either import_config/1, Path.wildcard/1, nor filelib:wildcard/1). What I am proposing instead is that we should encourage having only one config/ directory in root of the umbrella.

Additionally for configuring current application we should encourage users to use :env option of application specification instead of global configuration file.

Showing Posts 1 to 10

hubertlepicki

hubertlepicki

I do precise opposite. In apps/*/config.exs I only have:

use Mix.Config
import_config Path.join("..", "..", "..", "config", "config.exs")

and only have one instance of dev.exs, test.exs and prod.exs per whole project, instead of splitting this among multiple files.

It’s easier when the project becomes big to have the configuration consolidated in my opinion.

nsweeting

nsweeting

I prefer to keep app-specific config within their own directories. If I find that there is config that is common across multiple apps (ie. logger stuff), I will usually just create a new “logging” app that deals with all things logging. All the other apps then just add it as a dependency.

hauleth

hauleth OP

I delete these files at all, as apps/*/mix.exs already contain config_path: "../../config/config.exs" so all you need to do is to remove import_config "apps/*/config/config.exs" from root configuration and call it a day.

hubertlepicki

hubertlepicki

Yep, you can do that and it’s probably good for 99.9% of the cases. Leaving the files in allows you to handle the situation where app was started on it’s own, without other apps being started and give you the possibility to add some config option to handle that situation, but as I said it’s very rarely needed and your solution is good.

dimitarvp

dimitarvp

IMO the defaults clearly send the message of “have the bare minimum global configuration in the umbrella’s root config and put everything else in app-specific configs”. F.ex. the company’s brand name would go to the root config and be fetched from there instead of being copy-pasted in plain text in templates.

Perhaps the problem is that your current use case is not the same as this seemingly intended default?

hauleth

hauleth OP

But then it becomes more intense, ex. where should go logger configuration. Ok that is pretty simple, this is global configuration, so probably in root. But what when you are configuring metrics gathering? It should go to the top level or into application level? TBH I am more and more sure that configuration should be only global, and when you need to configure your application then you should put as much as possible configuration into compiler.app specs, so instead of having solution proposed by the Phoenix with :load_from_env set to true in config/prod.exs instead it should be:

def application do
  [
    # …
    env: [
      {MyAppWeb.Endpoint, load_from_env: true}
    ]
  ]
end

And then you can disable it in per-environment configuration. And apps/*/config directories should not exist at all, only global configuration. That would also encourage people to have sys.config as small as possible instead having enormous amount of cruft (often needed only in compile-time) there.

nsweeting

nsweeting

As mentioned above, you eliminate the need for all “global configuration”, which IMO, is less than ideal (ignoring the fact that mix config is global anyways :stuck_out_tongue:), by simply creating apps for those “global requirements” - ie. logging and metrics. My umbrella apps usually include both a logging and metrics app. These apps will do all the setup required for their domain. Any app that requires logging or metrics simply has to add [{:logging, in_umbrella: true}, {:metrics, in_umbrella: true}] to their deps. If your requirements for logging or metrics ever expand - you have an easy point in which to work on it. This becomes more pronounced if you ever need to add “sinks” for either logging or metrics that require runtime config. Having an app for these makes it very clear where that code would go.

Keeps things focused. Works for me. Might not for others…

hauleth

hauleth OP

But are you aware, that adding dependency has nothing to do with configuration? Configuration of the dependencies is always ignored (unless you use your own wrapper over Logger in logging, then maybe, but Logger application is still global). So this approach is even more confusing.

nsweeting

nsweeting

But are you aware, that adding dependency has nothing to do with configuration

Not exactly true. If I have a logging app that uses an external service, and it requires runtime config, adding it as a dependency ensures that that app is started and configured before any app that depends on it.

I’d also argue that in many ways, this approach can be seen as more simple. If you open up an umbrella app, and need to change something to do with logging - where would you go first? The global config? The per app config? Or the app named logging. In my mind - thats pretty clear.

hauleth

hauleth OP

TBH, I would go straight to global config, because you cannot configure Logger per application, both Erlang’s logger and Elixir’s Logger are global. I would somewhat agree if we would talk about metrics application, but logging for me is misleading.

Where Next? Top

Trending in Discussions Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
jtormey
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews