git post-receive hook bundle install

322 views
Skip to first unread message

Jörg

unread,
Mar 16, 2013, 1:57:35 PM3/16/13
to rubyversi...@googlegroups.com
Hi,

when pushing to git a remote (user: git) and executing a git post-receive hook rvm is not in the path.

I'm getting the following message when executing bundle install or rails -v in the post-receive hook:

remote: hooks/post-receive: line 37: rails: command not found
remote: hooks/post-receive: line 41: bundle: command not found

When manually adding the following to the path:

/usr/local/rvm/gems/ree-1.8.7-2012.02@gemset/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@gemset/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin

I get this message:

remote: /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [] (Gem::LoadError)
remote: from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
remote: from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems.rb:1231:in `gem'
remote: from /usr/local/rvm/gems/ree-1.8.7-2012.02@gemset/bin/bundle:18
remote: from /usr/local/rvm/gems/ree-1.8.7-2012.02@gemset/bin/ruby_noexec_wrapper:14

Is there another way to make rvm available in the git post-receive script? When using ssh with user git the path is there und bundle, rails -v, etc. work.

Thanks!

Jörg

unread,
Mar 17, 2013, 6:23:17 AM3/17/13
to rubyversi...@googlegroups.com
BTW RVM is a Multi-User install here. When trying to:

source /etc/profile
type rvm | head -1

in the port-receive script the output is the following:

remote: /etc/profile.d/rvm.sh: line 67: __rvm_add_to_path: command not found
remote: hooks/post-receive: line 18: type: rvm: not found

mpapis

unread,
Mar 18, 2013, 8:59:11 AM3/18/13
to rubyversi...@googlegroups.com
1) the environment in the hook is not the same as you log in, check the scripting page: https://rvm.io/workflow/scripting/ - I myself am fan of wrappers
2) the second problem with sourcing is most likely because you use shebang pointing to 'sh' like '#!/bin/sh' - rvm is not compatible with SH and therefor is not loaded in this mode, you would need to use bash (shebang like: `#!/usr/bin/env bash`)

Jörg

unread,
Mar 18, 2013, 4:41:38 PM3/18/13
to rubyversi...@googlegroups.com
Thanks a lot! I use shebang now pointing to:

#!/bin/bash -l

with the -l option to act as login shell.
Reply all
Reply to author
Forward
0 new messages