ruby-on-rails - 赫斯基显示 Bundler::RubyVersionMismatch 错误
问题描述
最近我尝试在我的应用程序中集成 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)
我的 rvm
=* ruby-2.5.0 [ x86_64 ]
ruby-2.5.3 [ x86_64 ]
ruby-2.6.1 [ x86_64 ]
注意:rails server
运行得很好,其他所有命令也是如此。
解决方案
更新ruby
您的版本Gemfile
:
ruby "2.5.1"
2.5.0
它有时会运行(因为和之间没有太多区别2.5.1
)并且“成功运行”基本上证明不了任何事情。
推荐阅读
- php - 带有 SSL 的 Laravel MySql 驱动程序
- maven - Atlassian Bamboo 无法使用分类器解决依赖关系
- .htaccess - 用问号将规则重写为stat?
- android - post runnable 能否在其运行的视图上获得空引用?
- asp.net - Google 地图信息窗口 - 使用 JavaScript 更改我的位置 - Asp.NET
- java - 在左侧而不是右侧显示某些语言
- mysql - Mysql Subselect 排名
- html - CSS 图像淡入淡出动画仅在第一次运行
- android - 安卓kotlin版本
- c# - 没有图形界面的访问窗口