Over a million developers have joined DZone.

Upgrade Rubygems And/or Specific Gems Themselves Via Capistrano

When a latest RubyGems is released (e.g. 0.9.5 recently) or Rails (e.g. 2.0.2) you might want to push those upgrades to all your production machines.

Add these two tasks to your deploy.rb capistrano file (add namespaces for cap2.0 if you like)

  desc "Updates RubyGems version"
  task :gem_update_system do
    sudo "gem update --system"

  desc "Install a RubyGem from remote source"
  task :gem_install do
    puts "USAGE: GEM=gemname cap gems_install" and next unless ENV['GEM']
    sudo "gem install #{ENV['GEM']} --no-ri --no-rdoc"

To upgrade rubygems and rails, for example:

cap gem_update_system
GEM=rails cap gem_install


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}