Adam Templeton
Adam Templeton

Reputation: 4617

How do you get different RVM gemsets to use different versions of Rails?

I'm working with RVM, and I made the mistake of installing the latest version of Rails (3.2.5) without creating a gemset first.

Now, a project I'm working on requires Rails 3.0.0 to be compatible, but when I create a new gemset, install Rails 3.0.0 and check my Rails version, it still says I've got 3.2.5

Do I just need to uninstall Rails from everywhere and reinstall into separate gemsets for this to work?

Upvotes: 2

Views: 227

Answers (2)

jordanpg
jordanpg

Reputation: 6516

It sounds like Rails 3.2.5 is a member of your global gemset, whose installations are inherited by each of that ruby's gemsets.

I would first take stock your gemsets with rvm gemset list, see if there's a difference between @global and the new gemset, and uninstall gems from the @global gemset if needed.

I think most of what you need to know is here: https://rvm.io/gemsets/basics/

Upvotes: 2

Bart Jedrocha
Bart Jedrocha

Reputation: 11570

If you run gem list -d rails you'll get an output similar to this.

*** LOCAL GEMS ***

rails (3.2.3)
    Author: David Heinemeier Hansson
    Homepage: http://www.rubyonrails.org
    Installed at: /Users/bjedrocha/.rvm/gems/ruby-1.9.3-p194@jwb

    Full-stack web application framework.

Note the installed at directive. The part after the @ indicates the gemset. So if you've installed Rails without first creating and switching to a named gemset, chances are that it is installed under the @global gemset (a default for RVM). If this is your case, I would switch into the global gemset and uninstall Rails. Once its uninstalled, you can switch back to your named gemset and it will use the Rails version installed in this gemset

rvm use 1.9.3@global
gem uninstall rails

rvm use 1.9.3@mygemset

Hope this helps

Upvotes: 4

Related Questions