Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuggestExtensions cop not working on JRuby #9145

Closed
boris-petrov opened this issue Dec 2, 2020 · 5 comments · Fixed by #9149
Closed

SuggestExtensions cop not working on JRuby #9145

boris-petrov opened this issue Dec 2, 2020 · 5 comments · Fixed by #9149
Labels

Comments

@boris-petrov
Copy link

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).

@bbatsov bbatsov added the bug label Dec 2, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 2, 2020

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!

@CKolkey
Copy link

CKolkey commented Dec 2, 2020

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.

@dvandersluis
Copy link
Member

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).

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Dec 2, 2020
…not available, or when there is no gemfile.
bbatsov pushed a commit that referenced this issue Dec 2, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 2, 2020

@boris-petrov
Copy link
Author

Thanks for so quickly resolving this! 1.5.1 works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants