bkeepers / dotenv

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

Prevent exception on Rails startup #487

Closed zspencer closed 9 months ago

zspencer commented 9 months ago

I'm not entirely sure if this is the "right" way to fix this (in fact, I'm pretty sure it's not...) I'm presuming that setting the ReplayLogger#level to log the most things will ensure it doesn't drop messages.

I noticed on a project that since the 3.0 release of dotenv-rails, the application would fail to start due to the ReplayLogger responding to #level as if it were a command to log a statement, rather than a query to determine the level the Logger is configured for.

You can see the exception here: https://github.com/zinc-collective/convene/actions/runs/7923719579/job/21633994956?pr=2210

The application in question is a Rails 7.1 app, running Ruby 3.2.

multiplegeorges commented 9 months ago

We were getting this and we tracked it down to a gem version issue.

We had (for various old reasons) gem "rails", "= 7.1.0". Once we loosened that up to gem "rails", "~> 7.1.0" it properly upgraded our dependencies and this issue went away.

@zspencer YMMV but that worked for us.

bkeepers commented 9 months ago

Thanks for taking time to work on this. I took an alternate approach in #492 and just made ReplayLogger extend Logger so it has all the functionality of a real logger.

zspencer commented 9 months ago

That sounds much wiser than my attempt! Thank you!