无法使用RVM管理的ruby版本运行rubocop

时间:2019-05-03 19:08:40

标签: ruby rvm rubocop

我正在使用rvm来管理红宝石版本。我正在使用ruby 2.5.0。我还已经在红宝石rubocop中安装了2.5.0宝石。运行rubocop时出现错误提示。

运行2.5.0时,我可以看到ruby版本rvm list。不确定rubocop仍在哪里以及如何寻找ruby 2.1

Unknown Ruby version: 2.1
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:189:in `parser_class'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:197:in `create_parser'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:154:in `parse'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:36:in `initialize'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:17:in `new'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:17:in `from_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:349:in `get_processed_source'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:118:in `block in file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:137:in `file_offense_cache'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:117:in `file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:105:in `process_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:82:in `block in each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `each'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `reduce'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:73:in `inspect_files'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:39:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:210:in `execute_runner'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:80:in `execute_runners'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:51:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/exe/rubocop:13:in `block in <top (required)>'
~/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/exe/rubocop:12:in `<top (required)>'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `load'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `<main>'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `<main>'

1 个答案:

答案 0 :(得分:1)

在项目根目录中创建ruboco.yml并添加以下行可解决此问题。 Ref

AllCops:
  TargetRubyVersion: 2.5.0