Overcommit support
Hi,
Overcommit is a gem that adds hooks on git actions,
The problem with Rubymine is that when committing from the UI it will use the system ruby for some reason ignore rvm in the project folder. Any ideas?
Please sign in to leave a comment.
The full output is:
21:33:35.201: cd /home/calin/Projects/patron/backend
21:33:35.205: git -c core.quotepath=false commit --only -F /tmp/git-commit-msg-0.txt -- app/models/user.rb
Running pre-commit hooks
Analyzing with RuboCop......................................[RuboCop] FAILED
/home/calin/.rvm/gems/ruby-2.2.1/gems/bundler-1.11.2/lib/bundler/definition.rb:402:in `validate_ruby!': Your Ruby version is 2.2.1, but your Gemfile specified 2.2.4 (Bundler::RubyVersionMismatch)
from /home/calin/.rvm/gems/ruby-2.2.1/gems/bundler-1.11.2/lib/bundler.rb:88:in `setup'
from /home/calin/.rvm/gems/ruby-2.2.1/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `<top (required)>'
from /home/calin/.rvm/rubies/ruby-2.2.1/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/calin/.rvm/rubies/ruby-2.2.1/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
✗ One or more pre-commit hooks failed
I can see the cd happening I wonder why the ruby version switch is not triggered, on that cd rvm should trigger and switch ruby versions unless rubymine does not use shell commands.
Hello,
Indeed another ruby SDK is being used, please vote for the corresponding request on our tracker:
https://youtrack.jetbrains.com/issue/RUBY-17869
As a workaround, try to set rvm SDK being used in your project as current from Terminal and launch RubyMine from it.
Voted, thank you for the work around, maybe you should mention that in the tracker request also.
Heartbreaking issue. The workaround does not help while on Ultimate why so?
BTW it does not work with RVM however, rbenv does the trick.
@Prikha Can you explain how you got overcommit to work with Rubymine and rbenv please?
@Tim Rubymine executes external ruby scripts with system ruby and ignores the one provided by RVM. Then I got rid of RVM and installed rbenv and rbenv gemset, which is smarter in sense of self-establishment. Then I have put
.ruby-version
ruby-2.4.2
.ruby-gemset
my-gemset
-global
and it did the trick - when Idea hits commit hooks, it is running ruby from rbenv.
Even though - it either passes or fails with a non-valuable message. So you have to run it manually to see the output if something failed.
@Prikha DO you start Rubymine from the terminal within the project directory? Also, Which gemset did you install overcommit into?
@Tim I start Rubymine(Actually I start IDEA with a plugin) from Apps on OS X. So not from project root. Overcommit is picked from current rbenv gemset. `which overcommit` points to `rbenv` shims.
Hope this helps.
I have the same issue, we run git hooks through lint-staged like this
This problem with rvm.
I tried to start RubyMine through a terminal in a project folder and with ENV variables but hooks don't work
> Which gemset did you install overcommit into?
We use it with npm package, but rubocop installed into project gemspec and works fine with RubyMine linters
Some output after commit
my .ruby-version file