I am using RVM. I wrote a Git pre-commit hook for the project:
#!/usr/bin/env ruby puts RUBY_VERSION puts `echo $PATH` exit(1)
which outputs this when starting git:
$ git ci -m 'foo' 1.8.7 /usr/libexec/git-core:/usr/bin:/usr/local/heroku/bin:/Users/mgoerlich/.rvm/gems/ ruby-2.0.0-p195@global /bin:/Users/mgoerlich/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/mgoerlich/.rvm/bin:/Users/mgoerlich/adt-bundle-mac-x86_64-20130219/sdk/platform-tools:/Users/mgoerlich/adt-bundle-mac-x86_64-20130219/sdk/tools:/usr/local/bin:/usr/local/sbin:/Users/mgoerlich/.dotfiles/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/core_perl:/Users/mgoerlich/bin:/usr/local/share/npm/bin:/usr/local/share/npm/bin
It seems to work with the wrong version of Ruby, because $PATH does not match bash or zsh or sh. Git seems to be manipulating $PATH . When starting manually, I get the following:
$ .git/hooks/pre-commit 2.0.0 /usr/local/heroku/bin:/Users/mgoerlich/.rvm/gems/ ruby-2.0.0-p195@global /bin:/Users/mgoerlich/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/mgoerlich/.rvm/bin:/Users/mgoerlich/adt-bundle-mac-x86_64-20130219/sdk/platform-tools:/Users/mgoerlich/adt-bundle-mac-x86_64-20130219/sdk/tools:/usr/local/bin:/usr/local/sbin:/Users/mgoerlich/.dotfiles/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/core_perl:/Users/mgoerlich/bin:/usr/local/share/npm/bin:/usr/local/share/npm/bin
In the output of the commit hook, two paths are added: one of them is /usr/bin , where the Ruby system executable is located.
Is this a known behavior? Can I somehow manipulate this? I know that I can point the full path to the correct Ruby version in shebang, but this is not what I want.
source share