How to change Ruby version when running git hooks in IDEA (git4idea)?
Answered
I use chruby on my Mac to have my own Ruby version.
In IDEA, it works when I commit in the console, but when I use the commit dialog in IDEA, I see that it uses the system Ruby version.
2026-02-11 17:08:47,740 [409824221] INFO - #git4idea.commands.GitHandler - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- git (LoadError)
2026-02-11 17:08:47,740 [409824221] INFO - #git4idea.commands.GitHandler - from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2026-02-11 17:08:47,740 [409824221] INFO - #git4idea.commands.GitHandler - from .git/hooks/post-commit:19:in `<main>'
How can I make IDEA use Ruby from chruby?
Please sign in to leave a comment.
IntelliJ inherits the environment variables from the shell instance it was started in. If you run the IDE via GUI, it will inherit the variables from the parent process like file explorer in Windows, display manager in Linux, etc. It is recommended to run the IDE using the terminal instance that contains the necessary environment variables.
https://youtrack.jetbrains.com/articles/SUPPORT-A-1837