Hey guys, continuing from my other thread I’m still building and exploring some compile-time stuff that Elixir can provide.
Right now I’m trying to operate on the Mix config files at compile-time, but I keep getting nil
values from the app keys. At first I thought that maybe the configs could only be read at runtime, but then I found this in the Mix.Config
doc page:
Configuration set using Mix.Config will set the application env, so that Application.get_env/3 and other Application functions can be used at run or compile time to retrieve or change the configuration.
Is there a specific way to retrieve the config values at compile-time, then? I’ve been trying both:
inside a macro
defmodule A do
defmacro test do
IO.inspect Application.get_env(:app, :key)
end
end
and just inside a module
defmodule A do
IO.inspect Application.get_env(:app, :key)
end
but I always get nil
. Any tips would be appreciated.