I'm not sure whether I've not done something wrong but just updating RuboCop from 1.4.2 to 1.5.0 and running it blows up with:
uninitialized constant RuboCop::CLI::Command::SuggestExtensions::Bundler
org/jruby/RubyModule.java:3760:in `const_missing'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:57:in `dependent_gems'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `block in extensions'
org/jruby/RubyHash.java:1751:in `select'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `extensions'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:15:in `run'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/command.rb:11:in `run'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli.rb:65:in `run_command'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli.rb:77:in `suggest_extensions'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `block in execute_runners'
org/jruby/RubyKernel.java:1897:in `tap'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/lib/rubocop/cli.rb:41:in `run'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/exe/rubocop:13:in `block in <main>'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/benchmark.rb:308:in `realtime'
/home/boris/project/build/.gems-rubocop/gems/rubocop-1.5.0/exe/rubocop:12:in `<main>'
org/jruby/RubyKernel.java:1009:in `load'
/home/boris/project/build/.gems-rubocop/bin/rubocop:23:in `<main>'
Disabling the cop fixes the issue. This is on Linux, using JRuby. I haven't installed/am not using Bundler (which, I guess, is the problem).
Hmm, it seems we've leveraged an API that exists only for MRI. @dvandersluis, please check if there's something we can use for JRuby, otherwise let's just make this a no-op for it.
I haven't installed/am not using Bundler (which, I guess, is the problem).
Indeed. The JRuby bit made me ignore the rest the ticket description. 馃槅 My bad!
Well, for added fun, I can report that I'm having the same issue using rubocop outside of bundler on MRI. Using ruby 2.6.6
uninitialized constant RuboCop::CLI::Command::SuggestExtensions::Bundler
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:57:in `dependent_gems'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `block in extensions'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `select'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `extensions'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:15:in `run'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/command.rb:11:in `run'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:65:in `run_command'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:77:in `suggest_extensions'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `block in execute_runners'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `tap'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:41:in `run'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/exe/rubocop:13:in `block in <top (required)>'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/home/ubuntu/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-1.5.0/exe/rubocop:12:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.6.6/bin/rubocop:23:in `load'
/home/ubuntu/.rbenv/versions/2.6.6/bin/rubocop:23:in `<main>'
edit:
I updated my global ruby to 2.7.2, did a fresh install of rubocop, and used a config only consisting of AllCops: NewCops: enable. Rubocop seems unresponsive, and when you send an interrupt (^C), it spits out:
uninitialized constant RuboCop::CLI::Command::SuggestExtensions::Bundler
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:57:in `dependent_gems'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `block in extensions'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `select'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:52:in `extensions'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command/suggest_extensions.rb:15:in `run'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/command.rb:11:in `run'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:65:in `run_command'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:77:in `suggest_extensions'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `block in execute_runners'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `tap'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/lib/rubocop/cli.rb:41:in `run'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/exe/rubocop:13:in `block in <top (required)>'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/ubuntu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.5.0/exe/rubocop:12:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.7.2/bin/rubocop:23:in `load'
/home/ubuntu/.rbenv/versions/2.7.2/bin/rubocop:23:in `<main>'
Same as before.
I don't think it's a JRuby issue specifically, but rather that bundler isn't guaranteed to be available (it's only a development dependency). A couple checks for bundler and the presence of a Gemfile should resolve this (and #9148, which is a different error message but the same cause).
RuboCop 1.5.1 is out https://github.com/rubocop-hq/rubocop/releases/tag/v1.5.1
Thanks for so quickly resolving this! 1.5.1 works like a charm!
Most helpful comment
Thanks for so quickly resolving this! 1.5.1 works like a charm!