puma / puma-dev

A tool to manage rack apps in development with puma
BSD 3-Clause "New" or "Revised" License
1.74k stars 107 forks source link

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

Closed amitsaxena closed 2 years ago

amitsaxena commented 3 years ago

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.

nonrational commented 3 years ago

Mitigated with https://github.com/puma/puma-dev/releases/tag/v0.16.0. See https://github.com/puma/puma-dev/pull/275

drinks commented 2 years ago

Ok to close this?