如何使用git hook post-receive中的特定rvm gemset进行bundle install?

时间:2021-03-02 00:19:34

So, I'm trying to implement a heroku-like deployment without using capistrano. To check and install gems I'm trying to use git hook and put the following commands in /hooks/post-receive:

所以,我试图在不使用capistrano的情况下实现类似heroku的部署。要检查并安装gem,我正在尝试使用git hook并将以下命令放在/ hooks / post-receive中:

bundle check || bundle install

But when I run git push I get:

但是当我运行git push时,我得到:

remote: hooks/post-receive: line 20: bundle: command not found. 

I understand that a hook probably launches commands from the wrong environment and somehow I have to switch rvm environment from hook. I tried to use rvm use 1.8.7@rails3 in post-receive but it didn't help. Any ideas?

我知道钩子可能从错误的环境启动命令,不知何故我必须从钩子切换rvm环境。我试图在post-receive中使用rvm使用1.8.7@rails3,但它没有帮助。有任何想法吗?

2 个解决方案

#1


6  

You might just have to make sure you source the user's environment at the top of the hook, for example:

您可能只需要确保在钩子顶部获取用户的环境,例如:

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

#2


1  

Maybe this gist will help you!

也许这个要点会帮助你!

Kudos to the gist owner!

感谢主人!

#1


6  

You might just have to make sure you source the user's environment at the top of the hook, for example:

您可能只需要确保在钩子顶部获取用户的环境,例如:

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

#2


1  

Maybe this gist will help you!

也许这个要点会帮助你!

Kudos to the gist owner!

感谢主人!