【发布时间】:2019-05-03 19:08:39
【问题描述】:
我正在使用rvm 来管理 ruby 版本。我正在使用红宝石 2.5.0。我还在 ruby 2.5.0 中安装了 rubocop gem。我在运行 rubocop 时遇到错误。
当我运行 rvm list 时,我可以看到 ruby 版本 2.5.0。不确定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>'
【问题讨论】:
-
您是否在
.rubocop.yml中配置了TargetRubyVersion: 2.1? -
不,我没有。我在哪里可以找到
.rubocop.yml?还是我需要创建一个?