3

请耐心等待,因为我是一个极端的新手,不太清楚我在说什么。

我正在尝试设置一个 Git 接收后挂钩来部署我的 Jekyll 站点,如此所述。它的内容是

#!/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每个实例中的变量都不同。

如果这就是问题所在,那就是我能想到的。我该如何解决?

4

2 回答 2

2

所以:

1)你的 shebang 是/usr/bin/env sh- 这不是 RVM 兼容的外壳,要么使用zsh要么bash

2)您需要以某种方式使用 RVM,当您通过ssh您已经使用过 RVM登录~/.bash_profile但在脚本中您没有加载 RVM 时,试试这个 shebang:

/home7/contenw6/.rvm/bin/rvm-shell 1.9.3-p194
于 2013-02-20T11:52:20.060 回答
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

希望这可以帮助。

于 2013-02-20T07:38:35.090 回答