繁体   English   中英

捆绑安装未从我的更新后挂钩运行

[英]bundle install not running from my post-update hook

我已经为我的项目设置了更新后挂钩。 我有一个推送到的裸仓库(/ var / git / myproject),还有一个运行我的应用程序的实时仓库(/ var / www / myproject)。 我还包括bundle installbundle exec rake db:migrate以安装gems和更新db。

以下是我的更新后挂钩

#!/bin/bash

echo "Pulling changes into Live..."
cd /var/www/myproject || exit
unset GIT_DIR
git pull origin master

# check if ruby app
if [ -f /var/www/myproject/Gemfile ];
then
  echo "  Ruby app detected..."
  bundle install --without development test
  bundle exec rake db:migrate # migrate database
fi

exec git-update-server-info

当我推送更改时,虽然收到以下消息(注意“未找到捆绑命令”错误):

martyn@localhost:~/www/myproject$ git push -u origin master
martyn@192.168.0.100's password: 
Counting objects: 832, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (783/783), done.
Writing objects: 100% (832/832), 487.70 KiB, done.
Total 832 (delta 434), reused 0 (delta 0)
remote: Pulling changes into Live...
remote: From /var/git/myproject
remote:  * branch            master     -> FETCH_HEAD
remote: Ruby app detected...
remote: hooks/post-update: line 13: bundle: command not found
remote: hooks/post-update: line 14: bundle: command not found
To 192.168.24.100:/var/git/myproject.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

为什么捆绑包没有运行? cd在脚本的实时应用程序的目录。 当我在终端我自己和我cd到活动目录并运行bundle install ,运行非常束是存在的。

您的钩子shell与您登录的钩子shell不同(钩子具有正确的PATH

您可以在开始时尝试使用挂钩脚本:

#!/bin/bash -l

(请参阅此答案

-l参数在登录外壳程序中执行命令,这意味着它从外壳程序配置文件继承了您的路径和其他设置。

或者,您可以通过添加钩子的第一行来确保脚本获得与当前会话相同的环境:

$ source $HOME/.bash_profile # single user RVM setup
$ source /etc/profile        # multi user RVM setup

或者(最终替代方案),您可以添加(在调用bundle之前)(对于单用户rvm安装)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM