The error
[39mERROR! the application :core has a different value set for path [:chaser_after] inside key Core.Emails.Chaser during runtime compared to compile time. Since this application environment entry was marked as compile time, this difference can lead to different behaviour than expected:
* Compile time value was set to: 3
* Runtime value was set to: 5
The code
@chaser_after Application.compile_env!(:core, [__MODULE__, :chaser_after])
@time_unit Application.compile_env!(:core, [__MODULE__, :time_unit])
def chaser_after do
DateTime.utc_now()
|> DateTime.add(@chaser_after, @time_unit)
end
config
//dev
config :core, Core.Emails.Chaser,
chaser_after: 3,
time_unit: :minute
//prod
config :core, Core.Emails.Chaser,
chaser_after: 3,
time_unit: :day
import Config
//stagingg
# remaining config same as prod, as even in staging to. since controlled by env var
import_config "prod.exs"
# staging config overrides prod ones
config :core, Core.Emails.Chaser,
chaser_after: 5,
time_unit: :minute
//test
config core, Core.Emails.Chaser,
chaser_after: 0,
time_unit: :nanosecond
For different environement , re compilation happens , why then its being logged as error.
The what to use:
- compile_env! or wihtout !
- fetch
- get_env