From 1d9d14b8de67daab169d10293e1f09901734c445 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 16 Feb 2024 09:29:24 -0500 Subject: [PATCH] Use `abort` instead of `warn(); exit` in boot.rb env check (#29209) --- .rubocop.yml | 6 ------ config/boot.rb | 11 +++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a8310489ea..dce33eab30 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -96,12 +96,6 @@ Rails/FilePath: Rails/HttpStatus: EnforcedStyle: numeric -# Reason: Allowed in boot ENV checker -# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsexit -Rails/Exit: - Exclude: - - 'config/boot.rb' - # Reason: Conflicts with `Lint/UselessMethodDefinition` for inherited controller actions # https://docs.rubocop.org/rubocop-rails/cops_rails.html#railslexicallyscopedactionfilter Rails/LexicallyScopedActionFilter: diff --git a/config/boot.rb b/config/boot.rb index 717de85f20..70ffe22c04 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,8 +1,15 @@ # frozen_string_literal: true unless ENV.key?('RAILS_ENV') - warn 'ERROR: Missing RAILS_ENV environment variable, please set it to "production", "development", or "test".' - exit 1 + abort <<~ERROR + The RAILS_ENV environment variable is not set. + + Please set it correctly depending on context: + + - Use "production" for a live deployment of the application + - Use "development" for local feature work + - Use "test" when running the automated spec suite + ERROR end ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)