How to Install Ruby Gems When Using Rvm

how can i install rubygems with rvm ? what is the difference between the two?

Yes, you can install gems with rvm. Use:

rvm use 1.9.2 # Make sure you're using the installed version
rvm gem install --version '3.0.3' rails

Updated to include specific version of the gem.

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.

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.

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.

rvm 'gem install' wants to install latest gems. Can it be set to automatically install the latest compatible versions?

Gems have dependencies that may not be compatible with older versions of ruby (have methods that appeared in later versions of ruby). If you need to put this gem on your ruby version, you need to create a gemfile manually and register versions that are compatible with the new gem. Or install an older gem selenium-webdriver that fits Your version of ruby

How do you update rubygems using rvm and ree?

The problem, I think, is the initial command (or what you expect that command to do):

$ rvm ree gem update --system

That tells rvm to pass the gem update --system to the gem under ree, but it doesn't switch you to that particular Ruby interpreter. You continue using whatever interpreter you have set in that shell (whether by default or because you switched manually earlier in the shell session).

As an example, my default interpreter is Ruby 1.9.2. If I pass this command: rvm 1.9.1 gem install pony, then the Pony gem is installed for Ruby 1.9.1. However, I'm still using Ruby 1.9.2 after that installation is finished. If I enter irb and try require 'pony', I get a load error. If I run rvm 1.9.1 and then enter irb, Pony is installed and loads fine.

So as Brian says in his comment to your post, you could switch manually with rvm use ree. Alternatively, you could switch your initial command to this:

$ rvm ree
$ gem update --system
$ gem --version


Related Topics



Leave a reply



Submit