请耐心等待我,因为我是一个极端的新手,并不太清楚我在说什么。
我正在尝试设置一个Git post-receive挂钩来部署我的Jekyll网站,如here所述。其内容是
#!/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
我正在回复PATH
以进行问题排查。如果我通过ssh登录并使用~/git/jekyll.git/hooks/post-receive
手动执行脚本,一切正常,控制台读取
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.
然而,当我从笔记本电脑上git push deploy master
时,我收到此错误:
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
在我看来,当post-receive
执行git push
挂钩时,正在使用错误的红宝石(1.8.7,可能是系统的?)。请注意,PATH
变量在每个实例中都不同。
如果这就是问题,那就是我能想到的。我该如何解决这个问题?
答案 0 :(得分:2)
这样:
1)你的shebang是/usr/bin/env sh
- 这不是与RVM兼容的shell,使用zsh
或bash
2)你需要以某种方式使用RVM,当你通过ssh
登录时已经通过~/.bash_profile
使用了RVM,但是在脚本中你没有加载RVM,试试这个shebang:
/home7/contenw6/.rvm/bin/rvm-shell 1.9.3-p194
答案 1 :(得分:0)
运行git master的用户没有使用rvm正确设置ruby。
首先,你必须找出哪个用户在遥控器上运行Git(它可能是一个名为“git”的用户)。找到用户后,将~/.rvm/
目录复制到该用户的主目录。例如,如果您的用户名是bob,并且运行git的用户名为gitter,那么您必须执行以下操作:
sudo rm -rf /home/gitter/.rvm
sudo cp -R /home/bob/.rvm/ /home/gitter
如果您家中没有.rvm目录,则以下内容可以提供帮助:
sudo rm -rf /home/gitter/.rvm
希望这有帮助。