class Dotenv::Rails
def env
check which rake tasks are being run to determine the environment.
When running `rake`, the Rails application is initialized in development, so we have to
The current environment that the app is running in.
def env @env ||= if defined?(Rake.application) && Rake.application.top_level_tasks.grep(TEST_RAKE_TASKS).any? env = Rake.application.options.show_tasks ? "development" : "test" ActiveSupport::EnvironmentInquirer.new(env) else ::Rails.env end end