You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 19, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 19, 2023. It is now read-only.
despite having the rvm stuff in my bash_profile and bashrc i can't get this hook to use the rvm ruby when called with the shebang #!/usr/bin/env ruby. seems to work fine at the terminal, does git abandon all environment variables before running hooks?
Looks like it prepends PATH with /usr/bin (/usr/libexec/git-core:/usr/bin to be exact), thus the system Ruby is the first one it finds.
I can think of two solutions right now: Either use the complete path to your version of Ruby as the shebang (e.g. /usr/local/rvm/bin/ruby-1.9.2-p290@projectX, see Using RVM with Cron for more details), or use a wrapper shell script that sources your RVM environment before execing the Ruby script.
using the path to the rvm ruby as the shebang isn't enough since below we do "which ruby". you can't actually use the wrapper scripts as shebangs either, they require being passed the ruby script as an argument. we also use "erb" without any path setup.
i can get everything to work by manually replacing that line with:
but it'd be nice to generalize. i guess we could do some hackery around looking if there's a ${HOME}/.rvm/wrappers/default like we do with rbx. there's a confusing git issue about whether this is even supposed to be the case: magit/magit#498 (comment)
I think pretty much the only solution would be to restore the original $PATH by removing the first two entries. That way, rvm/rbenv should be used to get whatever Ruby you set.
However, a possible downside is that this may have unintended side effects, like some git porcelain suddenly not working any more. And it's brittle as hell, since Git may change this behavior in future.
I've just pushed 8c302a1, could you test with that commit and see if it works then? If it does, then maybe we can come up with a sane way to restore the original $PATH without possibly breaking everything.
Activity
cypher commentedon Feb 15, 2013
Looks like it prepends PATH with
/usr/bin(/usr/libexec/git-core:/usr/binto be exact), thus the system Ruby is the first one it finds.I can think of two solutions right now: Either use the complete path to your version of Ruby as the shebang (e.g.
/usr/local/rvm/bin/ruby-1.9.2-p290@projectX, see Using RVM with Cron for more details), or use a wrapper shell script that sources your RVM environment beforeexecing the Ruby script.ericcj commentedon Feb 15, 2013
using the path to the rvm ruby as the shebang isn't enough since below we do "which ruby". you can't actually use the wrapper scripts as shebangs either, they require being passed the ruby script as an argument. we also use "erb" without any path setup.
i can get everything to work by manually replacing that line with:
/Users/ej/.rvm/wrappers/default/erb -xT - views/admin/users/index.erb | /Users/ej/.rvm/wrappers/default/ruby -wc
but it'd be nice to generalize. i guess we could do some hackery around looking if there's a ${HOME}/.rvm/wrappers/default like we do with rbx. there's a confusing git issue about whether this is even supposed to be the case: magit/magit#498 (comment)
cypher commentedon Apr 9, 2013
I think pretty much the only solution would be to restore the original
$PATHby removing the first two entries. That way, rvm/rbenv should be used to get whatever Ruby you set.However, a possible downside is that this may have unintended side effects, like some git porcelain suddenly not working any more. And it's brittle as hell, since Git may change this behavior in future.
I've just pushed 8c302a1, could you test with that commit and see if it works then? If it does, then maybe we can come up with a sane way to restore the original
$PATHwithout possibly breaking everything.