#547·dotenv

Using `dotenv/load` causes double loading (and logging) of env when using rails

Author: fsatelerCreated May 13, 2026Updated May 13, 2026

On a regular rails application, that requires dotenv/load, env is loaded twice: once at dotenv/load time and once at rails initialization.

bash
% cat test.rb
require 'rails'
require 'dotenv/load'

require_relative 'config/environment'

% bundle exec ruby test.rb
[dotenv] Loaded .env.development.local
[dotenv] Loaded .env.development
[dotenv] Loaded .env.development.local
[dotenv] Loaded .env.development

I believe this is because the rails initializer is inconditional: https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/rails.rb#L107