gpt4 book ai didi

rvm - 未使用正确的 Ruby 的接收后 Hook

转载 作者:行者123 更新时间:2023-12-04 13:43:59 25 4
gpt4 key购买 nike

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

我正在尝试设置一个 Git 接收后 Hook 来部署我的 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钩子(Hook)作为 git push 的结果执行,使用了错误的 ruby (1.8.7,大概是系统的?)。请注意 PATH每个实例中的变量都不同。

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

最佳答案

所以:

1) 你的shebang是/usr/bin/env sh - 这不是 RVM 兼容的 shell,要么使用 zshbash
2) 当您通过 ssh 登录时,您需要以某种方式使用 RVM您已经通过 ~/.bash_profile 使用过 RVM但在你不加载 RVM 的脚本中,试试这个 shebang:

/home7/contenw6/.rvm/bin/rvm-shell 1.9.3-p194

关于rvm - 未使用正确的 Ruby 的接收后 Hook ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14974367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com