bkeepers / dotenv

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

Manually check optional Rails dependency version #481

Closed bkeepers closed 9 months ago

bkeepers commented 9 months ago

This adds a manual check for the Rails version before loading the railtie.

Fixes #480

mvz commented 9 months ago

~How about moving all of the Rails integration to dotenv-rails instead?~

Oh, I see the integration was recently moved into dotenv on purpose.

Earlopain commented 9 months ago

Would it make sense to raise instead? When requiring this file, I expect it to work and warnings may or may not be seen. Rails itself for example raises when requiring files that require dependencies that are missing/not satisfied.

https://github.com/rails/rails/blob/9aeb1de2455e2988a90a49f73f87b60a58bcd173/activesupport/lib/active_support/cache/redis_cache_store.rb#L3-L11 https://github.com/rails/rails/blob/9aeb1de2455e2988a90a49f73f87b60a58bcd173/activesupport/lib/active_support/message_pack.rb#L3-L11

bkeepers commented 9 months ago

@Earlopain I debated about that. I decided not to because of all the unpredicable ways people use dotenv (like in another gem that still has Rails <6.1 in their build matrix). I would really prefer to raise, but I feel uneasy about it. 🤔