boddhisattva boddhisattva - 2 years ago 150
Ruby Question

How to Downgrade from Ruby 1.9.2 to Ruby 1.8.7 to run Rails 2.0.2

I want to downgrade the Ruby version I have installed(Ruby 1.9.2) on Ubuntu 10.04 OS so that I can use the appropriate version of Ruby 1.8.7 to run Rails 2.0.2. I am using the older version of Rails for project purpose.

If I am using Rails 2.0.2 with Ruby 1.9.2 it gives me an error saying cant convert Enumerator into an array.

I thought I could use rvm, but I am not sure if its suitable for downgrade.

I get the following in the terminal when I use the command rvm list known

[email protected]:~$ rvm list known
# MRI Rubies

# JRuby

I get the following in the list of installed ruby packages on using the command dpkg -l | grep ruby

[email protected]:~$ dpkg -l | grep ruby
ii libdbm-ruby 4.2 DBM interface for Ruby
ii libdbm-ruby1.8 DBM interface for Ruby 1.8
ii libgdbm-ruby 4.2 GDBM interface for Ruby
ii libgdbm-ruby1.8 GDBM interface for Ruby 1.8
ii libopenssl-ruby 4.2 OpenSSL interface for Ruby
ii libopenssl-ruby1.8 OpenSSL interface for Ruby 1.8
ii libreadline-ruby 4.2 Readline interface for Ruby
ii libreadline-ruby1.8 Readline interface for Ruby 1.8
ii libruby1.8 Libraries necessary to run Ruby 1.8
ii libtcltk-ruby 4.2 Tcl/Tk interface for Ruby
ii libtcltk-ruby1.8 Tcl/Tk interface for Ruby 1.8
ii rdoc 4.2 Generate documentation from ruby source file
ii ruby 4.2 An interpreter of object-oriented scripting
ii ruby-elisp 4.2 Emacs-lisp ruby-mode for Ruby
ii ruby-full 4.2 Ruby full installation
ii ruby1.8 Interpreter of object-oriented scripting lan
ii ruby1.8-dev Header files for compiling extension modules
ii ruby1.8-elisp ruby-mode for Emacsen
[email protected]:~$ ^C

Do I need to uninstall Ruby 1.9.2 and only then freshly install Ruby 1.8.7 or can I switch versions?. If I can switch versions please direct me on how to set the path from Ruby 1.9.2 to Ruby 1.8.7. Or if there is some other way please let me know.

If I have to uninstall Ruby 1.9.2 and then freshly install Ruby 1.8.7 please let me know how can I go about it. I tried the following commands to uninstall Ruby 1.9.2 but it didn't seem to find the Ruby 1.9.2 package.

sudo aptitude remove ruby

sudo aptitude remove ruby 1.9.2p0

sudo purge ruby

sudo aptitude purge ruby 1.9.2p0

When I checked for the current version of Ruby installed it shows:

[email protected]:~/Downloads/rubygems_postextract/rubygems-1.4.1$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

[email protected]:~/Downloads/rubygems_postextract/rubygems-1.4.1$ which ruby

Thanks for your help..!!

Answer Source

Whole point of RVM is so that you can have multiple versions of Ruby and switch among them easily..

rvm install 1.8.7 #or some specific version - choose from the rvm list known
rvm use 1.8.7
rvm gemset create rails202 #create a gemset called "rails202" for Ruby 1.8.7
rvm [email protected] #make the gemset the current selection
gem install rails -v 2.0.2 #install rails (just for this gemset!)
#now, we have a gemset called "rails202" in Ruby 1.8.7.
#anytime we want to use it, we do:
rvm [email protected]
#create as many gemsets needed, eg for rails 3.0.3 on Ruby 1.8.7 we can do the
#similar as above. Then to use the new gemset just do:
rvm [email protected]
#et voila! we are now using Rails 3.0.3 on Ruby 1.8.7 !
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download