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? 

 

5
10 comments
Avatar
Permanently deleted user

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.

0

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.

1
Avatar
Permanently deleted user

Voted, thank you for the work around, maybe you should mention that in the tracker request also.

 

0

Heartbreaking issue. The workaround does not help while on Ultimate why so? 

0

BTW it does not work with RVM however, rbenv does the trick.

0

@Prikha Can you explain how you got overcommit to work with Rubymine and rbenv please?

0

@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.

0

@Prikha DO you start Rubymine from the terminal within the project directory? Also, Which gemset did you install overcommit into?

0

@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.

0

I have the same issue, we run git hooks through lint-staged like this

"*.rb":
- bundle exec rubocop --auto-correct --color --display-style-guide --force-exclusion

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

 

❯ Running tasks for *.rb

✖ bundle exec rubocop --auto-correct --color --display-style-guide --force-exclusion
[FAILED] ✖ bundle exec rubocop --auto-correct --color --display-style-guide --force-exclusion
✖ bundle exec rubocop --auto-correct --color --display-style-guide --force-exclusion:
home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/lockfile_parser.rb:95:in `initialize'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:83:in `new'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:83:in `initialize'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:234:in `new'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:234:in `to_definition'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:13:in `evaluate'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:34:in `build'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler.rb:135:in `definition'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler.rb:101:in `setup'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/bundler/setup.rb:20:in ` '
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from home_path/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
pre-commit: pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit: pre-commit: pre-commit: git commit -n (or --no-verify)
pre-commit:
pre-commit: This is ill-advised since the commit is broken.
pre-commit:


my .ruby-version file

2.5.5@project_name

 

0

Please sign in to leave a comment.