Upgrade from Ruby 1.8.7 to Ruby 1.9.2 on Ubuntu

Posted About 13 years ago. Visible to the public.

Note that you cannot currently use Ruby 1.9.2 with Rails 2 applications that use RSpec, so don't upgrade if that is your setup. The rspec-rails gem has a fatal bug Show archive.org snapshot that was only fixed for rspec-rails-2.x, which only supports Rails 3. There is no fix for the rspec-rails-1.3.x series of the gem which supports Rails 2.

Anyway, here are upgrade instructions if you only work with Rails 3 or don't use RSpec. You will lose all your gems in the process, but you can get them back easily if you have been using Bundler.

sudo apt-get uninstall ruby1.8 ruby
sudo apt-get install ruby1.9.1 ruby1.9.1-dev # this is actually Ruby 1.9.2
sudo ln -s /usr/bin/ruby1.9.1 /usr/bin/ruby
# Now download RubyGems from https://rubygems.org/pages/download
tar xvzf rubygems-1.x.x.tgz
cd rubygems-1.x.x
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.9.1 /usr/bin/gem
sudo gem install bundler

You will now need to run bundle install in your projects to get your gems back.

Henning Koch
Last edit
Over 11 years ago
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-03-25 20:51)