Rvm: How to Use Gems from a Different Ruby

RVM: How to use gems from a different ruby?

You need to check out gemsets and export your current gems.

rvm gemset export

Read the gemset docs for more information.

User specific gems with RVM

Using RVM in multi user mode requires:

  1. RVM is installed using sudo not root user.
  2. All users wanting to install rubies / gems must be in the group rvm (an extra use case is OSX wher even you are in rvm group when checked with id1 - it could be still not effective for the shell and restart is needed)

The extra use case is mixed mode where only parts of RVM are in system and user can create gemsets in $HOME, read more about it at RVM site: https://rvm.io/rvm/install

Best way to upgrade to Ruby 2.3 through rvm while keeping all your gems?

EDIT

This question has an answer here: RVM: How to use gems from a different ruby?

$ rvm gemset copy $oldversion 2.3.0    ## Assign or replace $oldversion with old version name

ORIGINAL

Before installing Ruby 2.3, get a list of your installed gems and their versions using gem list. Then, after you install Ruby 2.3, use rvm to set 2.3 as the new default:

$ rvm install 2.3.0
$ rvm --default use 2.3.0

If you use Bundler, gem install bundler and then bundle install in all your project directories. This should install all of the gems relevant to your work.

If you don't use Bundler, or if you have gems installed that aren't part of any project's Gemfile, then you will want to go through the list of gems and their versions that you made earlier and gem install each of them, using -v to specify the version.

How do I use RVM and create globally available gems?

There is something called the global gemset, and it is shared between all your gemsets of a certain ruby-version. But you can't share gems between ruby-versions.

However, what you can do is create a list of gems that will be installed automatically when adding a new ruby version. That is described here. In short: edit a file called ~/.rvm/gemsets/global.gems to contain the list of gems you want to be there for each ruby-version.

Hope it helps.

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

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.

installing gems using rvm

There's a permission issue with your .gem folder. Make sure the owner is your current user.

sudo chown -R tee /home/tee/.gem

If it doesn't work, remove the .gem folder. It is automatically created when you update the gem cache.

Also, make sure you never used sudo with rvm.

How do I install Ruby gems when using RVM?

It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.

Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.

With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.

So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.

So, yep, you're gonna have to run gem install rails, etc.

Hope that helps clear the confusion.

(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.

Using a specific ruby version : RVM and bundler

Specify Ruby version as follows in Gemfile:

ruby '1.9.3'

Also try:

gem uninstall sass
gem install sass

Note: You should ideally be using a version of Ruby greater than 2.1.0 by now.



Related Topics



Leave a reply



Submit