ruby-on-rails - git post-receive hook 没有运行 bundle install

标签 ruby-on-rails ruby linux git bundle

我在运行接收后 Hook 时遇到问题,如下所示:

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

我正在从本地推送到远程,但出现此错误:

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

当我在服务器上克隆我的存储库并推送时, Hook 运行并且一切都很好。 从我的本地机器推送时,为什么推送不会触发 bundle 命令有什么想法吗?

谢谢!

最佳答案

尝试将此行添加到您的接收后 Hook (至少在您的第一个 bundle ... 调用之前):

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

在 Unix 系统上,rvm 自动将这一行添加到 ~/.bash_profile。在任何非 bash 上下文(crontab、git hooks)中,您必须手动添加它。

关于ruby-on-rails - git post-receive hook 没有运行 bundle install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13372609/

相关文章:

ruby-on-rails - 未定义的方法 `first_name'

python - 如何在 python setup.py 中修改文件?

c - Linux fork : pid reuse

linux - 在 linux 命令参数中添加\之前的 $

mysql - Rails 中对数据库的灵活请求

javascript - 无法加载 zurb 基础 JavaScript

Ruby - 优雅地比较两个枚举器

ruby-on-rails - 安装 rvm "bash/root/.rvm/scripts/rvm No such file or directory"

ruby-on-rails - Rails 4 应用程序中未定义的方法类 `all'

javascript - Jquery Custom Scroll with Rails .each 循环