`bundle: command not found` or `Could not find RubyGem bundler (>= 0)` During Capistrano Deployment? No Problems!

Don’t you just hate it when you get the following errors during a Capistrano deployment?

bundle: command not found
Could not find RubyGem bundler (>= 0) (Gem::LoadError)

In fact, even if you don’t use bundler, you might still get errors like this:

rake: command not found
Could not find RubyGem rake (>= 0) (Gem::LoadError)

It turns out this has something to do with the $PATH and $GEM_HOME variables.

So here’s the quick fix.

Log in to your deployment server, as a root user, add the following line to /etc/ssh/sshd_config:

PermitUserEnvironment yes

Don’t forget to restart ssh:

/etc/init.d/ssh restart

Now, log in as the deployment user, and create ‘~/.ssh/environment’ with the following content:

PATH=/usr/local/rvm/gems/ruby-1.9.2-p0/bin:/bin:/usr/local/rvm/rubies/ruby-1.9.2-p0/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.2-p0

* The above paths are for your reference only, obviously you need to work them out for your server environment. The only thing you need to make sure is that the GEM_HOME’s path matches one from the PATH.

Now, to verify this all work, you may use cap shell to start a new shell session and try out your commands.

Deploy PHP Websites Using Capistrano (and Git)

The Rails deployment flow is really smooth thanks to the powerful (and easy to use) Capistrano.

Capistrano not only works with Rails and other Ruby code bases, but also code bases in any programming languages, such as PHP!

Here is an overview of what I did to get one of our PHP production sites up and running with Capistrano.

Read more ...