Fix Capistrano with RubyGems 1.6

Updated . Posted . Visible to the public.

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)

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.

Tobias Kraze
Last edit
Keywords
netssh, ruby, deployment, conflict
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2011-03-09 14:16)