demarches-normaliennes/config/initializers/env_vars.rb
2024-08-22 09:26:48 +02:00

15 lines
621 B
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
# Ensure that the environment variables defined in the reference env vars file
# are present in the execution environment.
#
# This protects against an out-to-date environment leading to runtime errors.
if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake'
reference_env_file = File.join('config', 'env.example')
Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, _value|
if !ENV.key?(key.to_s)
raise "Configuration error: `#{key}` is not present in the process environment variables (declared in `#{reference_env_file}`)"
end
end
end