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

.env load behaviour at odds with dotenv #702

Open
PhilT opened this issue Feb 6, 2018 · 5 comments · May be fixed by #711
Open

.env load behaviour at odds with dotenv #702

PhilT opened this issue Feb 6, 2018 · 5 comments · May be fixed by #711

Comments

@PhilT
Copy link

PhilT commented Feb 6, 2018

With dotenv if you have a var in .env and also have an environment variable of the same name it will use the environment variable over the .env defined one. This allows you to define a .env but then override it in certain environments with environment variables.

With foreman, however, it seems .env always overrides any environment variables. I think it makes sense to mirror what dotenv does.

For my specific use case I'm running up foreman within a docker container to start some sidekiq processes as well as the app server. However, as the .env contains a MQ_HOST var of localhost I can't override it in the environment of the docker-compose.yml to point to the rabbitmq docker service as would be expected when executing the command directly.

This allows a default local development configuration as well as a docker based development config.

@NAR8789 NAR8789 linked a pull request May 9, 2018 that will close this issue
@arcreative
Copy link

I can't even get my processes to start with dotenv gem. Being able to run both is preferable for me since rake tasks need the environment vars as well, and that's obviously not getting run through foreman.

@arcreative
Copy link

Nevermind, I had an old version of foreman somehow... but I'm still +1 on this and #711 :-)

@andrewmcodes
Copy link

@PhilT Is this still an issue?

@PhilT
Copy link
Author

PhilT commented Mar 27, 2019

@andrewmcodes Take a look at the referenced PR above. There is a workaround.

@stevenharman
Copy link

The workaround mentioned in #711 is to pass the --env=/dev/null option, which effectively causes foreman to load an empty file. This then allows dotenv (and/or dotenv-rails) to take over and load the hierarchy of files, with overrides, etc…. I don't love this workaround, but it makes sense.

I wonder if we can improve it by adding some sort of sticky configuration to disable .env loading all together? That way we could set it once, and then not have to remember to pass the --env=/dev/null every time going forward. Thoughts?

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

Successfully merging a pull request may close this issue.

4 participants