Rubocop使用错误版本的Ruby-失败

时间:2019-02-05 10:31:12

标签: ruby rubocop

我已经使用rvm implode重新安装了RVM,Ruby和所有gem。当我运行rubocop时,收到一个错误,指出它正在使用2.5(我没有明确安装,但似乎是RVM的Ruby 2.5.1附带的)

请注意我用* *突出显示的行-这可能是问题所在吗?

$ which ruby
/Users/Will/.rvm/rubies/ruby-2.5.1/bin/ruby
$ rvm use 2.5.1
Using /Users/Will/.rvm/gems/ruby-2.5.1
$ rubocop
Inspecting 604 files


0 files inspected, no offenses detected
Unknown Ruby version: 2.5
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:131:in `parser_class’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:138:in `create_parser’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:94:in `parse’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:36:in `initialize’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:17:in `new’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:17:in `from_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:334:in `get_processed_source’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:110:in `block in file_offenses’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:121:in `file_offense_cache’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:109:in `file_offenses’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:100:in `process_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:78:in `block in each_inspected_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `reduce’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each_inspected_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:67:in `inspect_files’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:39:in `run’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/cli.rb:82:in `execute_runner’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/cli.rb:28:in `run’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/bin/rubocop:13:in `block in <top (required)>'
*/Users/Will/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime’*
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/bin/rubocop:12:in `<top (required)>'
/Users/Will/.rvm/gems/ruby-2.5.1/bin/rubocop:23:in `load’
/Users/Will/.rvm/gems/ruby-2.5.1/bin/rubocop:23:in `<main>'
/Users/Will/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval’
/Users/Will/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'

1 个答案:

答案 0 :(得分:3)

version 0.52.0中,Rubocop添加了对Ruby 2.5的支持。但是您正在使用0.49.1

您需要将Rubocop至少更新到0.52.0版,或者甚至更好地更新到最新版本(今天是0.63.1)。

根据您的设置,您只需要运行bundle update rubocop,或者您可能首先需要在Gemfile中指定所需的版本。