2016-01-03 163 views
1

我使用rubocop檢查程序使用flycheck模式。使用rubocop檢測Emacs 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文件不會引發錯誤。某些項目發生錯誤。

+1

rubocop可以從命令行運行嗎?通常它發生的原因有兩種,1)rubocop.yml有一些問題2)你使用的是rvm,如果它是一個rubocop.yml問題,你將很容易通過從命令行運行rubocop來看到它,如果它是rvm,那麼你可能需要使用rvm(https://github.com/senny/rvm.el) – goromlagche

回答

1

很難告訴你發生了什麼,而不會在命令行上看到它。

我有同樣的錯誤,事實證明我使用的是較老版本的Rubocop,而FlyCheck使用一個不理解的選項(--display-cop-names)調用rubocop可執行文件。

因此,從命令行運行它,併發布結果,然後我們可以嘗試診斷問題。

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,然後重新安裝它,並在兩個項目中再次運行。