bkeepers / dotenv

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

Raise if using an unsupported Rails version #485

Open bkeepers opened 9 months ago

bkeepers commented 9 months ago

Requested by @Earlopain in https://github.com/bkeepers/dotenv/pull/481#issuecomment-1945621945.

This will raise an error for people using just the dotenv gem with an unsupported Rails version. Those using dotenv-rails with an old Rails version will properly resolve to dotenv 2.x. The problem is that this will raise an error for those using dotenv in more advance ways (e.g. they could still call Dotenv.load manually and that would be completely fine).

I'm not convinced that this is the right thing to do, so I think I'm going to let this sit for now. If anyone has thoughts one way or the other, please share them.

Earlopain commented 9 months ago

Ok, I see. I haven't thought about the automatic requiring that happens now.

Would it be possible to instead delay this error to time of use? I don't know the places where this could be happening, but the initializer seems run at some point and will pose trouble on Rails < 6.1. https://github.com/bkeepers/dotenv/blob/09caa4d08403770bf70bdd9f4b2404ea99e5312f/lib/dotenv/rails.rb#L96-L97

Does that make sense? Or perhaps just at self.load. I'm not certain on the order of execution here and in what ways things can happen.