simultenious rails versions on single machine

hi all,
   can i install different rails versions on single machine like rails
1.2.2, 1.2.6, 2.0,2.1 etc to workout different applications in different
rails versions. if yes, how? currently i've rails 1.2.6 and if i run
command as "gem install rails", will it overwrite my current rails
version? what should i do to keep older and new both versions at the
same time?


The command "gem install rails" will overwrite some commands, in
particular the rails command in you path, but the rails command is
also part of the gem. Your current rails command will be 1) in your
path and 2) in some location like /usr/local/lib/ruby/gems/1.8/gems/
rails-*/bin where the * stands for the version of rails.

Just move rails into the "/vendor" directory of each project using
subversion (old versions) or git (newer versions).

For example, I use rails 1.2.3 for zena cms so I use (in the vendor
# svn export -r 6633 rails


And if you need to run the actuals rails executable you can specify
the version you want eg rails _1.2.6_ to run version 1.2.6 (assuming
you have the corresponding gem)

Dhaval Phansalkar wrote:

   thanks for reply. wt i was thinking that i could install all those
versions on single machine and just change RAILS_GEM_VERSION in
config/environment.rb file. can this be done?

Hi Dhaval,

Yes, it can be done. When you install a gem, you can pass it -v to tell
it what version you want. Without -v, the latest version is installed.
So install rails 2.1 _right now_, you could do

gem install rails

But if you want to install 1.2.6, you would do

gem install rails -v 1.2.6

gem actually has pretty good help.

gem help commands

is a good place to start. Then you can get specific with

gem help install


Ar Chron wrote:

Dhaval Phansalkar wrote:

hi all,
   can i install different rails versions on single machine like rails
1.2.2, 1.2.6, 2.0,2.1 etc to workout different applications in different
rails versions. if yes, how?

Freezing the appropriate Rails gems into your application(s) is your
friend in this case...

rake rails:freeze:gems

although I don't know if that takes an argument for version or not.

"Proof of this last statement is left as an exercise for the reader"

thanks for the reply people. i thought this task is easy but it seems a
bit tricky ;).

   i checked the help. thanks for the info :slight_smile:

@Ar Chron
   freezing rails seems to be a good option. i tried it on a sample
application and it worked fine. but i've a question here.if i freez my
appl to the current rails version(1.2.6) and install 2.0. later on,just
in case, if i want to go back to the previous ver i.e. 1.2.6, i'll do
gem install "rails -v1.2.6". in that case, will i have to install all
other gems also like hpricot,mongrel etc?


You can can get all parts of rails (activerecord, actionpack, etc) using subversion ( or git (forgot website name). The command using subversion would be:

cd vendor

svn export -r 6633 rails

Replace “6633” by the revision number containing the versions that you want. Doing this, you get to use specific copies for your app, without using the gems for rails stuff. You can use the “previous change”, “next change” on the old trac browser to find the revision you need (if you know rails version):

You end up with a folder containing:

your app

± app

± …
± vendor

± rails

± actionmailer

± actionpack
± actionwebservice
± activerecord
± …


gem install rails -v=<%=version you want to install%>

eg: gem install rails -v=1.2.5

will install the rails version 1.2.5 for you. Infact this option is
available while installing any gems.
With the option "-v=" will always install the latest version of and

You can freeze a different version of rails for an different project.
In config/environment.rb specify which rails version you wan to use
for that particular project.