Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 849
John Bachir Avatar asked Dec 07 '10 03:12

John Bachir


People also ask

How do I install specific versions of gems?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

How do I change my gem version?

To automate the process of switching gems, pop . ruby-version and . ruby-gemset files in your project root. Pop the version of Ruby and name of the gemset you want to use inside them and RVM wil select the correct gemset when you cd into your project directory.

How do I activate a different version of Rake?

The newer versions of rake can be activated by supplying an optional first argument, that is the gem version. Alternatively, if you have an older version of rake you can update the rake script manually to include this parameter (or specify any specific version you want).


1 Answers

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.

like image 180
Daniel Vartanov Avatar answered Sep 21 '22 13:09

Daniel Vartanov