Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my gem 'dotenv-rails' variables not loading?

  • gem 'dotenv-rails' is required in gemfile test and development environments.
  • .env file is saved in root
  • I believe variables use correct syntax; USERNAME=username
  • I am using Rails 5.0.4
  • I have not required 'dotenv-rails' anywhere, as the docs do not suggest that I need to.

When playing in the console, the only way I can access the variables is by calling, Dotenv.load in each session. Suggesting that Dotenv.load should be called somewhere in config of my app.

like image 508
jbk Avatar asked Jul 29 '17 14:07

jbk


1 Answers

Add Dotenv::Railtie.load to your config/application.rb

like image 117
Lucas Moulin Avatar answered Oct 09 '22 21:10

Lucas Moulin