Does a library’s configuration need to be declared as runtime to work correctly in a production release?
0 reputation · 29 Aug 2023, 06:55 UTC
When developing an Elixir application with Mix, configuration files in config/ are loaded on each start, so changes to config/prod.exs take effect immediately. In a production release built with mix release or Distillery, static configuration is compiled into sys.config; only values wrapped in {:system, "VAR"} or placed in config/runtime.exs are read from the environment at startup.
The unresolved decision is determining which configuration keys should be declared as runtime versus compile‑time, especially when third‑party libraries may expect a value during compilation. Moving a key to config/runtime.exs can prevent the release from baking in a development value, but it may break libraries that read the key at compile time or rely on it being present in sys.config.
Does marking a key as runtime guarantee it will be read at startup even if a dependency expects it at compile time? Which configuration keys are safe to move to runtime without breaking library behavior? When should a library author provide both compile‑time and runtime paths for the same setting?