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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
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)