How to do bundle install using specific rvm gemset from git hook post-receive?

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:

bundle check || bundle install

But when I run git push I get:

  • Developing gems and using them in rails projects with bundler, is there a faster way?
  • How to get mongrel working with bundler?
  • How to use a branch in a fork of rails in a project with bundler
  • Bundler for javascript, or how to source control external javascript files
  • How to manage dependencies between my ruby projects?
  • How to organize development of Rails App and multiple Engines
  • 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?

  • git complains about untracked file
  • Tidy or drop git history for release?
  • Unable to git clone
  • Is GIT a good solution for large projects like Laravel or projects using Smarty Templating
  • Git: How to move contents of gh-pages branch to docs/ directory preserving history?
  • How to configure git to include my name in commits
  • 2 Solutions collect form web for “How to do bundle install using specific rvm gemset from git hook post-receive?”

    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

    Maybe this gist will help you!

    Kudos to the gist owner!

    Git Baby is a git and github fan, let's start git clone.