使用rubocop的Emacs flycheck模式出错

时间:2016-01-03 05:44:07

标签: ruby-on-rails emacs rubocop flycheck

我使用rubocop checker的flycheck模式。

当我打开一些rb文件时,

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.

并且flycheck模式无效

我还使用了抛射物/抛射物轨道模式。但是某些项目的rb文件不会引发错误。某个项目出现错误。

3 个答案:

答案 0 :(得分:1)

如果没有看到它在命令行上运行,很难告诉你发生了什么。

我遇到了同样的错误,事实证明我使用的是旧版本的Rubocop,FlyCheck正在调用rubocop可执行文件,其中包含一个它不理解的选项(--display-cop-names

从命令行运行它,然后发布结果然后我们可以尝试诊断问题。

答案 1 :(得分:0)

为了它的价值,我看到了这一点:

/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>'

但是这个问题只出现在我的一个项目中; rubocop在另一个项目中执行得很好!

所以我卸载了rubocop,运行gem update --system,然后重新安装它,它在两个项目中再次运行。

答案 2 :(得分:0)

我不知道为什么,但是之后:

$ rubocop --auto-gen-config

在我的Rails APP_ROOT中,现在一切正常。