-
Notifications
You must be signed in to change notification settings - Fork 90
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
How to "source .env" in Elixir to "load" Environment Variables from .env file? #18
Comments
Considering just "porting" over |
@nelsonic check few already available options https://github.com/avdi/dotenv_elixir https://github.com/BlakeWilliams/envy . |
@cse-tushar thanks. |
OptionParse can handle ini files including .env. You only need add the section to the file. Like in this example where I am using .env file to set the database in Phoenix. https://gist.github.com/hipertracker/5338d75e220b200dc92f6be3af65f5b5 |
@hipertracker that's a good gist for the DIY approach. 👍 |
Scenario:
we have an
.env
file that contains several environment variables.We want to run the equivalent of
source .env
but from within our
config.exs
file, so that it's run each time the app is started(such that the
source .env
command does not need to be run manually)We tried the following three variants:
Sadly none of them worked for setting the environment variables.
Ended up cobbling together the following code:
Which does work.
But it so many lines of code ...
Does anyone know why the
source .env
does not work?The text was updated successfully, but these errors were encountered: