Read more

Fix Capistrano with RubyGems 1.6

Tobias Kraze
March 09, 2011Software engineer at makandra GmbH

After updating your RubyGems, you will probably not be able to run Capistrano any more, but receive an error similar to this:
can't activate net-ssh (= 2.0.22) for [], already activated net-ssh-2.1.0 for [] (Gem::LoadError)

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

If you have Bundler installed, you can use bundle exec to avoid this problem as follows:

Create a gemfile at ~/.capistrano/Gemfile (or at some other sensible place), that only contains these 2 lines:
source 'http://rubygems.org'
gem 'capistrano'
gem 'capistrano-ext' # You need this for multistage deployments
gem 'hoptoad_notifier' # Add this for projects that use Hoptoad and Capistrano integration

Run bundle install in the same directory.

Now you can use Capistrano again by prepending BUNDLE_GEMFILE=~/.capistrano/Gemfile bundle exec, i.e.
BUNDLE_GEMFILE=~/.capistrano/Gemfile bundle exec cap deploy

I suggest making a shell alias. For the Bash, append this to your ~/.bashrc:
alias cap='BUNDLE_GEMFILE=~/.capistrano/Gemfile bundle exec cap'

Now you can once again simply run cap deploy.

Posted by Tobias Kraze to makandra dev (2011-03-09 15:16)