views:

106

answers:

4

I am wondering about rails versions.

I am in a project directory:

  • when I run "rails --version" I get v2.3.4.
  • when I run "script/about", I get a different answer, v2.1.1.
  • in environment.rb, I have the line "RAILS_GEM_VERSION = '2.1.1' ...."

Okay, so where is this rails v2.1.1? I thought maybe in vendor, but no, should there be? I know that my installed (v2.3.4.) rails is at /usr/bin/rails.

Someone clear this up for me?

A: 

You could have it installed in any number of places.

What does gem list rails show?

BJ Clark
A: 

Rails is a ruby gem - you can see all installed versions by gem list rails. And it should be installed in your gems directory.

Toms Mikoss
+3  A: 

There are several possibilities.

./config/environment.rb has a constant RAILS_GEM_VERSION that's used unless you override that value, and it generally indicates which version of rails your app was built with. When you run script/about, that constant value should show by default.

gem list rails will show you what versions are installed locally, and you can have several versions around at any given time.

Finally, Rails apps can "freeze" the current version of rails so that they can count on the right version of rails libraries for their app, by executing

rake rails:freeze:gems

You can undo that by running

rake rails:unfreeze

You can also update the config by typing rake rails:update, or freeze to a specific version with rake rails:freeze:edge RELEASE=2.2.2.

JasonTrue
Strange, my webhost linux maybe is a little pooched. Since there seemed to be no v2.1.1. I did "gem install -v=2.1.1 rails" and it installed it in ./ruby/gems/gems/rails-2.1.1. I noticed that there are also 2 other versions nearby. Running "gem list rails" still only shows v2.3.4. I am headed towards more heartache as my app still won't run. :(
rtfminc
I think you should try rake rails:freeze:edge RELEASE=2.1.1 to get the exisiting code to run, then work on testing what parts of your app are depending on deprecated or changed features. (In spite of the :edge marker, most versions can be frozen.)
JasonTrue
A: 

/usr/bin/rails is a wrapper for the project creation script of the version of rails installed. It's just an executable ruby script that uses Ruby Gems to select the correct version of rails.

Where the rails gems are installed depends on where your gems are installed.

To find out where the gems are stored run the following ruby statements. Either in irb or as executable script.

require 'rubygems'
puts Gem.path.join("\n")

It should print out at least two directories. One local directory in your home folder for gems installed without administrator privileges, and one global directory for gems installed with administrator privileges. Your rails gems will be in one of those folders.

On my system this outputs /usr/lib/ruby/gems/1.8 and ~/.gem/ruby/1.8

EmFi
you can also run 'gem env' to see where gems are stored
Jeff Paquette