From 4b9f99b3931b754e36061e4676a295a63a4b71f6 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Tue, 9 Aug 2022 18:26:10 +0900 Subject: [PATCH] [Fix #10893] Fix an error when running `rubocop` without `bundle exec` Fixes #10893. This PR fixes an error when running `rubocop` without `bundle exec`. --- changelog/fix_an_error_for_no_bundle_exec.md | 1 + lib/rubocop/feature_loader.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/fix_an_error_for_no_bundle_exec.md diff --git a/changelog/fix_an_error_for_no_bundle_exec.md b/changelog/fix_an_error_for_no_bundle_exec.md new file mode 100644 index 00000000000..b5ee5d65dfb --- /dev/null +++ b/changelog/fix_an_error_for_no_bundle_exec.md @@ -0,0 +1 @@ +* [#10893](https://github.com/rubocop/rubocop/issues/10893): Fix an error when running `rubocop` without `bundle exec`. ([@koic][]) diff --git a/lib/rubocop/feature_loader.rb b/lib/rubocop/feature_loader.rb index 32317a18451..e80fe0fbcab 100644 --- a/lib/rubocop/feature_loader.rb +++ b/lib/rubocop/feature_loader.rb @@ -30,7 +30,9 @@ def initialize(config_directory_path:, feature:) end def load - ::Kernel.require(target) + # Don't use `::Kernel.require(target)` to prevent the following error: + # https://github.com/rubocop/rubocop/issues/10893 + require(target) rescue ::LoadError => e raise if e.path != target