bkeepers / dotenv

A Ruby gem to load environment variables from `.env`.
MIT License
6.6k stars 506 forks source link

environment specific env not loaded when using require: 'dotenv/load' #479

Closed raldred closed 9 months ago

raldred commented 9 months ago

When including dotenv require: 'dotenv/load' as per: https://github.com/bkeepers/dotenv?tab=readme-ov-file#load-order

Environment specific .env files such as .env.development are ignored.

Steps to reproduce

  1. Load dotenv as above in your Gemfile
  2. Define a TEST_VAR in both .env and .env.development
  3. Run rails c and observe the value of TEST_VAR.

Rerun steps with dotenv in Gemfile without require: 'dotenv/load' And the value of the env var is as expected.

Overriding on the shell works as expect TEST_VAR=shell rails c

Expected behavior

The value of TEST_VAR should be that contained in the .env.development

Actual behavior

The value of TEST_VAR is actually that contained in the .env file

System configuration

dotenv version: 2.8.1 Rails version: 7.1.3 Ruby version: 3.3.0

raldred commented 9 months ago

https://github.com/bkeepers/dotenv/issues/478 😵‍💫