Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.get_env #34

Open
plamb opened this issue Jan 5, 2016 · 4 comments
Open

System.get_env #34

plamb opened this issue Jan 5, 2016 · 4 comments

Comments

@plamb
Copy link

plamb commented Jan 5, 2016

I may be totally looking at this wrong and would love to be corrected.

It looks like if you did the config like this:

config :my_app, mailgun_domain: "https://api.mailgun.net/v3/mydomain.com",
                mailgun_key: System.get_env("MAILGUN_API_KEY")

It's going to pull the environment variable at compile time since the config happens in a macro? The problem, I'm running into is that at runtime the env variable may be different than the compile time one (if there's even a compile time one there).

@speg
Copy link

speg commented Feb 10, 2016

I've been battling this off and on for a few days too. I've been trying to follow this with the Heroku deploy guide. But the environment variables don't work there. Everything seems to work okay locally though? I don't even know how I can configure the Mailgun client without using the keys directly since the environment variables don't seem to be available at compile time.

Oh, I see. You have to explicitly state which config vars you want to export for compile time.

https://github.com/HashNuke/heroku-buildpack-elixir#specifying-config-vars-to-export-at-compile-time

@vitalis
Copy link

vitalis commented Feb 15, 2016

I have the same issue with Heroku, if the config is set during compile time it cannot be changed by changing ENV variable, the app must be recompiled.
Will be glad to help with this issue.

@geofflane
Copy link

geofflane commented May 31, 2016

System.get_env("MAILGUN_API_KEY") is a compile time value. That gets converted by Mix.Config into a sys.config file at compile time and the value of the environment variable at compile time is used.

On top of that, the config macro in this libray is expanded at compile time as well, and caches the value from the Mix.Config/sys.config. So the value that will be in it is the one that is set at compile time only.

Short answer: The configuration of this app doesn't support changing the configuration at runtime which is kind of broken.

@rradz
Copy link

rradz commented Jun 1, 2016

@geofflane My little patch should help with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants