5

I've started using Elixir + Phoenix Framework and started incorporating the addict library for user registration/authentication.

The docs for addict tell me to update the config.exs for the :addict app.

config :addict, not_logged_in_url: "/error",
                db: MyApp.MyRepo,
                user: MyApp.MyUser,
                    :

Replacing the db and user values did not take affect till I ran mix deps.compile for the addict code to pick up the configs.

Now my question is, is it assumed to run mix deps.compile when you make changes to config.exs?

The addict docs don't state this and for a newcomer like me, this isn't really obvious. I only realized this when I actually looked into addict's code and saw that it was being set at compile time via a module attribute (thus the necessity to run mix deps.compile).

Daisuke Shimamoto
  • 5,206
  • 6
  • 32
  • 37
  • 1
    To expand on this (after a little experimentation; I'm not entirely sure), `Application.get_env…` reading from config.exs seems not to pick up new values without recompiling, whether you do the `get_env` in a module attribute or inside a function that's called at run-time. http://stackoverflow.com/a/28912658/6962 suggests you want a third-party lib if you need runtime config. – Henrik N Feb 27 '16 at 10:44

1 Answers1

11

You need to recompile dependencies only if they have compile time configuration. Compile time configuration as such is not very common, so you should ping the addict folks and ask them to have better instructions to what happens when someone configures addict after it was compiled. Or convince them to avoid the compile time configuration in the first place if they can.

José Valim
  • 50,409
  • 12
  • 130
  • 115