Recently I tried integrating husky on my application for pre-commit formatting. I am only using rubocop to test the commit but it gives out an error when I try to commit.
My 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"
}
}
The error it gives
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)
My rvm
=* ruby-2.5.0 [ x86_64 ]
ruby-2.5.3 [ x86_64 ]
ruby-2.6.1 [ x86_64 ]
NOTE: rails server
runs just fine and so does every other commands.