Hello. Based on a reporting bug (which was not bug ),
@josevalim
said I can not use Application.put_env
inside compile time macro like this:
This makes it so Mix believes the build of your dependency stale because a compile env flag is changing.
quote do
[:validate_derive, :sanitize_derive]
|> Enum.each(fn item ->
if is_nil(Application.compile_env(:guarded_struct, item)) do
Application.put_env(:guarded_struct, item, Keyword.get(unquote(opts), item))
end
end)
But I have question. is there a way to put env in compile time and access it inside run-time?
Thank you in advance.
Refs:
- Add warning around runtime modification of compile env Ā· elixir-lang/elixir@bd99dcc Ā· GitHub
- Mix cannot build a macro library used in another library when macro is called more than once in project modules Ā· Issue #13699 Ā· elixir-lang/elixir Ā· GitHub
- The dependency build is outdated error with getting lib from Github branch - #2 by shahryarjb