dotenv icon indicating copy to clipboard operation
dotenv copied to clipboard

dotenv-rails loads dev environment when running system tests with Rails 7

Open renchap opened this issue 2 years ago • 2 comments

When running system tests with Rails 7, the development environment variable files are loaded before loading the test ones.

This is most likely a bug in Rails 7, see https://github.com/rails/rails/issues/43937

I am opening the issue here in case somebody else is hitting this and wonders whats happening.

Steps to reproduce

  • In your .env.dev define a variable
  • Do not defineit in .env.test
  • Run your system tests

Expected behavior

Your env variable should not be defined

Actual behavior

The variable for dev env is defined

System configuration

dotenv version: 2.7.6

Rails version: 7.0.0

Ruby version: 3.0.3

renchap avatar Dec 19 '21 15:12 renchap

See #219 and #241. Basically Rails had a hack, and we removed it, but we can add it here: #441

etiennebarrie avatar Jan 07 '22 10:01 etiennebarrie

so is this fixed? the referred to PR is still open

ortonomy avatar Jun 28 '22 02:06 ortonomy

Seeing all these open/ignored PRs and issues makes me think again about using dotenv in my project. Kinda worrying that Kamal is using it by default.

Samuelodan avatar Jan 18 '24 03:01 Samuelodan

Seeing all these open/ignored PRs and issues makes me think again about using dotenv in my project. Kinda worrying that Kamal is using it by default.

@Samuelodan dotenv is an incredibly simple and stable library. I don't spend a lot of time maintaining it because it just works for me and most people, and I get tired of ungrateful users that complain and don't offer to help.

bkeepers avatar Jan 18 '24 16:01 bkeepers

Seeing all these open/ignored PRs and issues makes me think again about using dotenv in my project. Kinda worrying that Kamal is using it by default.

@Samuelodan dotenv is an incredibly simple and stable library. I don't spend a lot of time maintaining it because it just works for me and most people, and I get tired of ungrateful users that complain and don't offer to help.

@bkeepers

Hmm, I'm fairly new to all this, and I'm worried about how to manage .env files. Looking at dotenv, it gets recommended a lot, and Kamal even uses it, but I see these issues and PRs that were made a long time ago that didn't get as much as a response from the maintainer(s).

These didn't seem to me like ungrateful users because they did in fact offer to help.

But I hear open source work can be thankless and exhausting at times, so I apologize if my remarks made you feel that kinda away about your work.

Thanks for (building? and) maintaining this library. Chances are I'm overanalyzing the problem, so I'll give it a shot and see how it goes.

Samuelodan avatar Jan 18 '24 16:01 Samuelodan