Skip to content

Commit

Permalink
[Fix rubocop#12823] Fix uninitialized constant error
Browse files Browse the repository at this point in the history
Fixes the broken reference to `Bundler` on line 66
  • Loading branch information
amomchilov committed Apr 9, 2024
1 parent a4447ea commit 17624d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/fix_uninitialized_constant_bundler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12823](https://github.com/rubocop/rubocop/issues/12823): Fixed "uninitialized constant `RuboCop::Lockfile::Bundler`", caused when running RuboCop without `bundler exec` on codebases that use `rubocop-rails`. ([@amomchilov][])
13 changes: 8 additions & 5 deletions lib/rubocop/lockfile.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ def includes_gem?(name)
# @return [Bundler::LockfileParser, nil]
def parser
return @parser if defined?(@parser)
return unless @lockfile_path

lockfile = Bundler.read_file(@lockfile_path)
@parser = lockfile ? Bundler::LockfileParser.new(lockfile) : nil
rescue Bundler::BundlerError
nil
@parser = if defined?(::Bundler) && @lockfile_path
begin
lockfile = ::Bundler.read_file(@lockfile_path)
lockfile ? ::Bundler::LockfileParser.new(lockfile) : nil
rescue ::Bundler::BundlerError
nil
end
end
end
end
end

0 comments on commit 17624d9

Please sign in to comment.