I was using the dotenv gem to store environmental variables for development in a secrets file. The gem is no longer pulling the variables after upgrading ruby and rails on my computer. To try and track down the cause, and after a while of trying different options, I ended up creating two identical applications with just two differences. The ruby and the rails versions. One app is able to pull the environmental variables, the other returns nil. Any suggestions?
My Setup
Working application has
ruby "2.5.0"
gem 'rails', '~> 5.1.6'
Non-working app has
ruby "2.6.5"
gem 'rails', '~> 6.0.0'
What I have tried so far
- I read the information on the gem's site and tried adding
Dotenv::Railtie.load
to myconfig/application.rb
file. - Also, I tried adding
require: 'dotenv/rails-now'
in my Gemfile in case it was because of another gem issue. - I added
require 'dotenv/load'
to the files needing the variables. - I added
'require dotenv/load'
to various places in myconfig/application.rb
file
Each change I did individually and used byebug to check in the terminal if the variable was loaded. And each time the variable was still nil
.
Anything that I am missing? Any suggestions? Or should I switch to another gem? I hear that figaro may do the same thing, just never used it before. Thank you in advance for your help.