简体   繁体   English

Rubocop:RuboCop 在 `.ruby-version` 中发现未知的 Ruby 版本 3.1

[英]Rubocop: RuboCop found unknown Ruby version 3.1 in `.ruby-version`

I recently upgraded ruby version from 2.7.5 to 3.1.1 and when I try to run rubocop I get error Error: RuboCop found unknown Ruby version 3.1 in .ruby-version . Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7我最近将 ruby​​ 版本从 2.7.5 升级到 3.1.1,当我尝试运行rubocop时出现错误Error: RuboCop found unknown Ruby version 3.1 in .ruby-version . Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7 . Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7 Looking at the rubocop compatibility documentation it supports 3.1 version. . Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7 2.3、2.4、2.5、2.6、2.7 查看 rubocop兼容性文档,它支持 3.1 版本。 Any idea why I am getting the error?知道为什么我会收到错误吗?

.rubocop.yml: .rubocop.yml:

require: rubocop-rspec
AllCops:
  Exclude:
    - 'bin/*'
    - 'vendor/**/*'
Metrics/BlockLength:
  Exclude:
    - 'spec/**/*'
Metrics/LineLength:
  Exclude:
    - 'spec/**/*'
RSpec/AnyInstance:
  Enabled: false
RSpec/ExampleLength:
  Exclude:
    - 'spec/**/*'
Style/BracesAroundHashParameters:
  Enabled: false

Rubocop version 0.77.0 doesn't support newest ruby versions. Rubocop 版本0.77.0不支持最新的 ruby​​ 版本。 Make sure to use newer rubocop:确保使用较新的 rubocop:

gem install rubocop -v 1.14.0

You can check what ruby versions are supported by which rubocop version in lib/rubocop/target_ruby.rb file, KNOWN_RUBIES const.您可以在lib/rubocop/target_ruby.rb文件KNOWN_RUBIES const 中查看哪个 rubocop 版本支持哪些 ruby​​ 版本。

E. g.例如。 supported ruby versions for rubocop version 1.14.0: https://github.com/rubocop/rubocop/blob/v1.14.0/lib/rubocop/target_ruby.rb#L7 rubocop 1.14.0 版支持的 ruby​​ 版本: https ://github.com/rubocop/rubocop/blob/v1.14.0/lib/rubocop/target_ruby.rb#L7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM