簡體   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