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

When starting puma-dev existing ENV variables are overriden if they are specified in .env file #268

Closed
amitsaxena opened this issue Dec 17, 2020 · 2 comments
Labels

Comments

@amitsaxena
Copy link

It looks like when starting puma it looks for a .env file and loads all the environment variable without checking for existing ENV variables here:
https://github.com/puma/puma-dev/blob/master/dev/app.go#L243

This in turn overrides any ENV variables which might have already been set differently for various reasons (in my case via a docker compose file). This is in contrast with default dotenv behavior:
https://github.com/bkeepers/dotenv#why-is-it-not-overriding-existing-env-variables

By default, it won't overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use Dotenv.overload.

A practical use case is if I am running my application in dev environment standalone as well as containerized. I override the redis connection env variable in my docker compose file to be different from .env file (used by standalone version). By virtue of this behavior my connection to redis fails for the containerized version.

@amitsaxena amitsaxena changed the title When starting puma-dev existing ENV variables are overriden if they are specified in in .env file When starting puma-dev existing ENV variables are overriden if they are specified in .env file Dec 17, 2020
@nonrational
Copy link
Member

@drinks
Copy link
Contributor

drinks commented Jan 4, 2022

Ok to close this?

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

No branches or pull requests

3 participants