加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 捆绑安装没有从我的更新后挂钩运行

发布时间:2020-12-17 01:48:15 所属栏目:百科 来源:网络整理
导读:我为我的项目设置了更新后的挂钩.我有一个裸仓库(/ var / git / myproject),我推送到这个仓库,以及我的应用程序运行的实时存储库(/ var / www / myproject).我还包括bundle install和bundle exec rake db:migrate来安装gems和update db. 下面是我的更新后挂
我为我的项目设置了更新后的挂钩.我有一个裸仓库(/ var / git / myproject),我推送到这个仓库,以及我的应用程序运行的实时存储库(/ var / www / myproject).我还包括bundle install和bundle exec rake db:migrate来安装gems和update 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到脚本中的实时app目录.当我在终端自己,我cd到实时目录并运行捆绑安装它工作,所以捆绑就在那里.

解决方法

你的钩子外壳与你登录的钩子外壳不一样(并且具有正确的PATH)

您可以尝试在开头使用您的钩子脚本:

#!/bin/bash -l

(见this answer

The -l parameter executes the command in a login shell,which means that it inherits your path and other settings from your shell profile.

)

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

$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"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读