From f31172582cfe6da662bae6eec2e56aeeb1ce0488 Mon Sep 17 00:00:00 2001 From: Hartley McGuire Date: Sat, 1 Jul 2023 17:43:35 -0400 Subject: [PATCH] Add lower bound to Listen gem requirement An issue was recently opened with the following error message: ``` .../activesupport-7.0.6/lib/active_support/evented_file_update_checker.rb:120:in `start': undefined method `wait_for_state' for # ``` The issue is that the user was using Listen 3.0.8, however the `wait_for_state` method was [added][1] in Listen 3.3.0 We can make the error message a little better by defining a lower bound on Listen 3.3.0 (like we do for other optional dependencies): ``` .../bundler/rubygems_integration.rb:280:in `block (2 levels) in replace_gem': can't activate listen (~> 3.3), already activated listen-3.0.8. Make sure all dependencies are added to Gemfile. (Gem::LoadError) ``` There is definitely still room for improvement here, but this should be much more helpful in figuring out that the issue is a bad Listen version and not a bug in Rails. [1]: https://github.com/guard/listen/commit/12b4fc54a965f6a07c71bd53207ce8be8b0d7869 --- activesupport/CHANGELOG.md | 5 +++++ .../lib/active_support/evented_file_update_checker.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 64d8c617b1d6c..c187e73b7ca44 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,8 @@ +* Improve error message when EventedFileUpdateChecker is used without a + compatible version of the Listen gem + + *Hartley McGuire* + * Add `:report` behavior for Deprecation Setting `config.active_support.deprecation = :report` uses the error diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 04211082b785b..c024a6bc10774 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -gem "listen" +gem "listen", "~> 3.5" require "listen" require "set"