3

I use flycheck mode with rubocop checker.

when I open some rb file,

Checker ruby-rubocop returned non-zero exit code 1, but no errors from output: /Users/abc/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2157:in `method_missing': undefined method `this' for #<Gem::Specification:0x3fc38c8edb10 rubocop-0.35.1> (NoMethodError)
    from /Users/abc/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1056:in `find_active_stub_by_path'
    from /Users/abc/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:63:in `require'
    from /Users/abc/.rvm/gems/ruby-2.2.3/gems/rubocop-0.35.1/bin/rubocop:6:in `<top (required)>'
    from /Users/abc/.rvm/gems/ruby-2.2.3/bin/rubocop:23:in `load'
    from /Users/abc/.rvm/gems/ruby-2.2.3/bin/rubocop:23:in `<main>'
    from /Users/abc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
    from /Users/abc/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'

Checker definition probably flawed.

And flycheck mode is not working

I also use projectile / projectile-rails mode. But rb files of some projects are not raise errors. Error is occured some project.

Jaehyun Shin
  • 1,562
  • 14
  • 25
  • 1
    does rubocop runs ok from command line? generally it happens for two kind of reasons, 1) rubocop.yml has some issue 2) you are using rvm, if its a rubocop.yml issue you will easily able to see it by running rubocop from command line, if it is rvm, then you may need rvm-use (https://github.com/senny/rvm.el) – goromlagche Jan 03 '16 at 16:41

3 Answers3

1

Hard to tell you what is going on without seeing it run on the command line.

I had the same error, and it turned out I was using an older version of Rubocop, and the FlyCheck was calling the rubocop executable with an option that it didn't understand (--display-cop-names).

So run it from the command line, and post the results and then we can try to diagnose the problem.

Howard Abrams
  • 186
  • 2
  • 5
0

For what it's worth, I was seeing this:

/Users/alexmoore-niemi/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:2158:in `method_missing': undefined method `this' for #<Gem::Specification:0x3fce0dc538dc rubocop-0.47.1> (NoMethodError)
    from /Users/alexmoore-niemi/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:1057:in `find_active_stub_by_path'
    from /Users/alexmoore-niemi/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:64:in `require'
    from /Users/alexmoore-niemi/.rvm/gems/ruby-2.3.0/gems/rubocop-0.47.1/bin/rubocop:6:in `<top (required)>'
    from /Users/alexmoore-niemi/.rvm/gems/ruby-2.3.0/bin/rubocop:23:in `load'
    from /Users/alexmoore-niemi/.rvm/gems/ruby-2.3.0/bin/rubocop:23:in `<main>'
    from /Users/alexmoore-niemi/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/alexmoore-niemi/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

But this problem was only in one of my projects;rubocop executed fine in another project!

So I uninstalled rubocop, ran gem update --system, then reinstalled it, and it worked again in both projects.

Alex Moore-Niemi
  • 2,913
  • 2
  • 24
  • 22
0

I don't know why but after:

$ rubocop --auto-gen-config

in my Rails APP_ROOT, all works fine now.

aarkerio
  • 2,183
  • 2
  • 20
  • 34