From 7b6b10542d5dac2b50f2578143dc5d70120d1146 Mon Sep 17 00:00:00 2001 From: Xavier Noria <fxn@hashref.com> Date: Thu, 11 Apr 2019 22:43:45 +0200 Subject: improves the reloading disabled error message The original message from Zeitwerk is "can't reload, please call loader.enable_reloading before setup (Zeitwerk::Error)", which is not very informative for Rails programmers. Rails should err with a message worded in terms of its interface. --- activesupport/activesupport.gemspec | 2 +- .../lib/active_support/dependencies/zeitwerk_integration.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 546cc1797a..dd2340cdd3 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -34,5 +34,5 @@ Gem::Specification.new do |s| s.add_dependency "tzinfo", "~> 1.1" s.add_dependency "minitest", "~> 5.1" s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" - s.add_dependency "zeitwerk", "~> 2.1" + s.add_dependency "zeitwerk", "~> 2.1", ">= 2.1.2" end diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb index b0f7a3f9cc..f16a9f7e57 100644 --- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb +++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb @@ -9,7 +9,11 @@ module ActiveSupport module Decorations def clear Dependencies.unload_interlock do - Rails.autoloaders.main.reload + begin + Rails.autoloaders.main.reload + rescue Zeitwerk::ReloadingDisabledError + raise "reloading is disabled because config.cache_classes is true" + end end end -- cgit v1.2.3