赫斯基显示Bundler :: RubyVersionMismatch错误

问题描述 投票:-2回答:1

最近我尝试将husky集成到我的应用程序上以进行预提交格式化。我只使用rubocop来测试提交但是当我尝试提交时它会发出错误。

我的package.json

{
  "name": "asdf",
  "private": true,
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "{app,spec}/**/*.rb": [
      "bin/rubocop --require rubocop-rspec --safe-auto-correct",
      "git add"
    ]
  },
  "devDependencies": {
    "husky": "^1.3.1",
    "lint-staged": "^8.1.5"
  }
}

它给出的错误

husky > pre-commit (node v8.15.1)
↓ Stashing changes... [skipped]
  → No partially staged files found...
   ❯ Running linters...
     ❯ Running tasks for {app,spec}/**/*.rb
       ✖ bin/rubocop --require rubocop-rspec --safe-auto-correct
        git add

       ✖ bin/rubocop --require rubocop-rspec --safe-auto-correct found some errors. Please fix them and try committing again.

       /usr/lib/ruby/vendor_ruby/bundler/definition.rb:489:in `validate_ruby!': Your Ruby version is 2.5.1, but your Gemfile specified 2.5.0 (Bundler::RubyVersionMismatch)

我的房客

=* ruby-2.5.0 [ x86_64 ]
   ruby-2.5.3 [ x86_64 ]
   ruby-2.6.1 [ x86_64 ]

注意:rails server运行得很好,其他命令也一样。

ruby-on-rails ruby yarnpkg husky
1个回答
0
投票

更新ruby中的Gemfile版本:

ruby "2.5.1"

它偶尔运行(因为2.5.02.5.1之间没有那么多差异)并且“成功运行”基本上没有任何证据。

© www.soinside.com 2019 - 2024. All rights reserved.