How do I "activate" a different version of a particular gem?

John Bachir picture John Bachir · Dec 7, 2010 · Viewed 44.7k times · Source

I want to switch between rails 2.3.10 as the "active" gem for my OS, so that I can invoke it at the command line.

Is it possible to do this? I'm not using rvm. Maybe it's time to start.

I tried gem install rails --version=2.3.10, but that just makes sure that version of the gem is installed, it doesn't put it in /usr/bin/rails.

(I do already use bundler for my apps -- but haven't needed any precise control over gems at the OS level until now)

Answer

Daniel Vartanov picture Daniel Vartanov · Dec 7, 2010

If your problem is to run binaries of a certain version, then:

rails --version # => the latest version
rails _2.3.10_ --version # => Rails 2.3.10

This pattern (gem-binary _gem-version_) works for any gem binary.

Hope it helps.