Please bear with me, as I am an extreme newbie and don't quite know what I'm talking about.
I'm trying to set up a Git post-receive hook to deploy my Jekyll site, as described here. Its contents are
#!/usr/bin/env sh
GIT_REPO=$HOME/git/jekyll.git
TMP_GIT_CLONE=$HOME/tmp/jekyll
PUBLIC_WWW=$HOME/public_html
echo $PATH
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
echo "Run jekyll"
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd $HOME
echo "Remove temporary dir..."
rm -Rf $TMP_GIT_CLONE
echo "Temporary dir removed."
exit
I'm echoing PATH
for troubleshooting purposes. If I login via ssh and execute the script manually with ~/git/jekyll.git/hooks/post-receive
, everything works fine, and the console reads
remote$ ~/git/jekyll.git/hooks/post-receive
/usr/local/jdk/bin:/home7/contenw6/.rvm/gems/ruby-1.9.3-p194/bin:/home7/contenw6/.rvm/gems/ruby-1.9.3-p194@global/bin:/home7/contenw6/.rvm/rubies/ruby-1.9.3-p194/bin:/home7/contenw6/.rvm/bin:/usr/local/jdk/bin:/home7/contenw6/perl5/bin:/usr/lib64/qt-3.3/bin:/home7/contenw6/perl5/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home7/contenw6/ruby/gems/bin:/home7/contenw6/bin:/usr/local/bin:/usr/X11R6/bin:/home7/contenw6/ruby/gems/bin:/home7/contenw6/.rvm/bin
Cloning into '/home7/contenw6/tmp/jekyll'...
done.
Run jekyll
Configuration from /home7/contenw6/tmp/jekyll/_config.yml
Building site: /home7/contenw6/tmp/jekyll -> /home7/contenw6/public_html
Successfully generated site: /home7/contenw6/tmp/jekyll -> /home7/contenw6/public_html
Remove temporary dir...
Temporary dir removed.
However, when I git push deploy master
from my laptop, I receive this error:
laptop$ git push deploy master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 305 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: /usr/libexec/git-core:/usr/local/jdk/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/home7/contenw6/ruby/gems/bin:/home7/contenw6/.rvm/bin:/home7/contenw6/.rvm/bin
remote: Cloning into '/home7/contenw6/tmp/jekyll'...
remote: done.
remote: Run jekyll
remote: /home7/contenw6/ruby/gems/gems/yajl-ruby-1.1.0/lib/yajl/yajl.so: [BUG] Segmentation fault
remote: ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02
remote:
remote: hooks/post-receive: line 14: 30293 Aborted jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
remote: Remove temporary dir...
remote: Temporary dir removed.
To contenw6@contentioninvain.com:~/git/jekyll.git
154f467..80c8fcb master -> master
It seems to me that when the post-receive
hook is executed as a result of git push
, the wrong ruby (1.8.7, presumably the system's?) is being used. Note that the PATH
variables are different in each instance.
If that's the problem, that's as much as I can figure out. How do I fix this?
so:
1) your shebang is /usr/bin/env sh
- this is not RVM compatible shell, either use zsh
or bash
2) you need to use RVM somehow, when you login via ssh
you already used RVM via ~/.bash_profile
but in the script you do not load RVM, try this shebang:
/home7/contenw6/.rvm/bin/rvm-shell 1.9.3-p194