Skip to content

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

@fsateler

Description

@fsateler

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

% 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:

config.before_configuration { load }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions