Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git post-receive hook not running bundle install

I am having trouble running the post-receive hook as follows:

#!/bin/sh
unset $(git rev-parse --local-env-vars)
cd ~/commodity
git pull origin master
bundle install
bundle exec rake assets:precompile
thin restart

I am pushing from local to remote and I am getting this error:

Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 319 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: From /var/www/html/test
remote:  * branch            master     -> FETCH_HEAD
remote: Updating a06129c..c3c3da3
remote: hooks/post-receive: line 19: bundle: command not found
remote: hooks/post-receive: line 20: bundle: command not found
remote: hooks/post-receive: line 21: thin: command not found
error: cannot run hooks/post-receive: No such file or directory

When I clone my repository on the server and push, the hook runs and everything is great. Any ideas why the push wont trigger the bundle commands when pushing from my local machine?

Thanks!

like image 460
pudding Avatar asked Nov 14 '12 03:11

pudding


1 Answers

Try to add this line to your post-receive hook (at least before your first bundle ... call):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

On Unix systems, rvm adds this line automatically to the ~/.bash_profile. In any none-bash contexts (crontab, git hooks) you have to add it manually.

like image 111
Alex Avatar answered Oct 17 '22 16:10

Alex