Check the gem version number

My setup: Rails 3.0.9, Ruby 1.9.2

I want to check the gem version for my application through the Rails console. In my gemfile I have

gem 'rack', '1.2.3' 

Ran bundle install after. In the Rails Console

 >> Rack.version => "1.1" 

Any idea why?

UPDATE

 Gemfile.lock GEM remote: http://rubygems.org/ specs: actionpack (3.0.9) ... rack (~> 1.2.1) ... rack (1.2.3) rack-mount (0.6.14) rack (>= 1.0.0) warden (1.0.4) rack (>= 1.0) DEPENDENCIES ... rack (= 1.2.3) ... 

There are several versions of the rack listed in gemfile.lock .

+8
ruby-on-rails
source share
2 answers
 Rack.version 

will return the protocol version,

 Rack.release 

probably what you are looking for.

https://github.com/rack/rack/blob/master/lib/rack.rb#L14

Otherwise:

 Gem.loaded_specs["rack"] 

Example:

 ruby-head :006 > Gem.loaded_specs["rack"] => #<Gem::Specification name=rack version=1.3.2> ruby-head :007 > Gem.loaded_specs["rack"].version => #<Gem::Version "1.3.2"> ruby-head :008 > Gem.loaded_specs["rack"].version.to_s => "1.3.2" 
+22
source share

Perhaps you have several versions of the rack installed, try running the gem uninstall rack and see if you have two choices: Rack 1.1 and Rack 1.2.3. If so, select Uninstall Rack 1.1.

If this still does not work, just uninstall Rack and try running the package update.

I had this problem when I used several rake versions 0.8.7 and 0.9.2, it helped me.

-one
source share

All Articles