can be during mix phx.server or mix release. In the case of mix release, it is evaluated when (and where) the release is built. Dynamic values configured via System.get_env will get evaluated then and there. chicago elixir // 05.29.19 20
setting module attributes and reading from them. defmodule SwingSet do @config Application.get_env(:playground, SwingSet) # ... def kind() do @config[:kind] end end This means @config gets set at compile time, even if you are trying to do run-time eval. chicago elixir // 05.29.19 23
Bugs Are Coming config :playground, :osha safety: "${MUST_BE_HERE}" || raise ("MUST_BE_HERE wasn't") eye_protection: "${EYE_PROTECTION}" || "sunglasses" if $MUST_BE_HERE is not set, evaluates to "" , and we'll never get raise(...) chicago elixir // 05.29.19 25
the value with a raise if empty string — wait for Elixir 1.9 where mix release gets config/ releases.exs, config providers, etc. chicago elixir // 05.29.19 26
built in. — use Mix.Config so! deprecated, long live import Config — mix new will no longer generate a config/config.exs — Umbrella applications will no longer generate a apps/config/*.exs chicago elixir // 05.29.19 27
config, just like the same dependencies. Causes problems when different apps in the umbrella that need different config. Some libraries will allow you to get around that (ueberauth's otp_app: :playground). chicago elixir // 05.29.19 29
of the given environment variable. If value isn't set, returns nil or optional second arg as default. System.fetch_env/1 Returns an {:ok, value} if value present, or :error if not System.fetch_env!/1 Returns the value if present, or raises ArgumentError chicago elixir // 05.29.19 30