Closed martijnbolhuis closed 9 months ago
Thanks @martijnbolhuis! I'll get this released soon.
Hi! This change caused me some issues, so I'll write it here in lack of a better place in case somebody comes across the same problem.
It manifested as my test suite not being able to run because environment variables from .env.test.local
weren't loading. I was confused, but we very clearly were loading dotenv-rails
, and I assumed that would also load dotenv/rails
, which it no longer does.
The cause of events that lead to this issue is:
spec/spec_helper.rb
that doesn't load Rails.spec/rails_helper.rb
that does require "spec_helper"
, and then proceeds to load Rails.The reasoning is:
require "spec_helper"
.require "rails_helper"
Unfortunately inside of spec/spec_helper.rb
we're also using dotenv, so the series of events were:
require "rails_helper"
rails_helper
then does require "spec_helper"
spec_helper
then does require "dotenv"
, at this point Rails::Railtie is not defined, since Rails isn't loaded yet.config/application.rb
is loadedBundler.require(*Rails.groups)
require "dotenv-rails"
(we now want the Railtie)dotenv-rails
simply does require "dotenv"
, but since dotenv
is already loaded it stops here.The end-result is that dotenv/rails
is never required, even though we did require dotenv-rails
.
The fix for us is to adjust our Gemfile:
gem "dotenv", require: %w[dotenv dotenv/rails]
See issue https://github.com/bkeepers/dotenv/issues/490.