N5ken's technical blog

Just another WordPress.com site

Useful commands in RVM

RVM is a good tool for managing Ruby and Gems, so the following codes shows you how to use:

Ruby Management

Use a particular Ruby

$ rvm use 1.8.6

Equivalently (because of RVM’s defaults):

$ rvm 1.8.6

List Ruby interpreters available for installation

$ rvm list known
  # MRI Rubies
  [ruby-]1.8.6[-p399]
  [ruby-]1.8.6-head
  [ruby-]1.8.7[-p330]
  [ruby-]1.8.7-head
  ...bla bla bla

List Ruby interpreters you’ve already installed

$ rvm list

   ruby-1.8.6-p383:  ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.0.0]
   ruby-1.9.1-head:  ruby 1.9.2dev (2009-10-30 trunk 25559) [x86_64-darwin10.0.0]
   ...bla bla bla

Ruby information for the current shell

$ rvm info

rvm 0.0.49 (2009.09.24) [http://rvm.beginrescueend.com/]

ruby:
interpreter:  "ruby"
version:      "1.8.6"
...bla bla bla

Install a specific Ruby version, e.g.

$  rvm install jruby

or

$  rvm install 1.9.2

Switch to gems directory for current ruby

$ rvm gemdir

/Users/wayne/.gem/ruby/1.9.1

Switch to the system gems directory

$ rvm gemdir system

/Library/Ruby/Gems/1.8

Use the user set default ruby

$  rvm default

Use the system ruby (as if no rvm)

$  rvm system

Reset to pre-RVM state.

$  rvm reset

Uninstall RVM installed 1.8.7 version

$  rvm uninstall 1.8.7

Named Gem Sets
Examples of creating and changing gem sets

$ rvm 1.9.2-head
$ gem install rails -v 2.3.3

$ rvm gemset create rails222 rails126
Gemset 'rails222' created.
Gemset 'rails126' created.

$ rvm 1.9.2-head@rails222
$ gem install rails -v 2.2.2

$ rvm 1.9.2-head@rails126
$ gem install rails -v 1.2.6

$ rvm 1.8.7
$ gem install rails -v 1.2.3

If you are deploying to a server or you do not want to wait around for rdoc and ri to install for each gem then you can disable these for gem installs and updates. Place these two lines in your ~/.gemrc or /etc/gemrc:

install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: