Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get RVM to set correct gem path

Tags:

rvm

On a clean Mac OS X "Snow Leopard" install, I have a problem with RVM: It sets the Ruby path correctly but doesn't set the gem path. When I start a Rails server it mixes versions which doesn't work.

To illustrate:

$ rvm system
$ which ruby
/usr/bin/ruby
$ which rails
/usr/bin/rails
$ rvm use 1.9.2-head
Using /Users/m/.rvm/gems/ruby-1.9.2-head
$ rvm gem list

LOCAL GEMS
[...]
rails (3.0.7)
[...]

$ which ruby
/Users/m/.rvm/rubies/ruby-1.9.2-head/bin/ruby
$ which rails
/usr/bin/rails

$ echo $GEM_PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180:/Users/m/.rvm/gems/ruby-1.9.2-p180@global

$ echo $PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180/bin:/Users/m/.rvm/gems/ruby-1.9.2p180@global/bin:/Users/m/.rvm/rubies/ruby-1.9.2p180/bin:/Users/m/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Any ideas what might be wrong?

like image 753
m.. Avatar asked Apr 30 '11 07:04

m..


People also ask

Which is better RVM or Rbenv?

RVM is easier to install than Rbenv, RVM has more features than Rbenv, RVM includes a built-in Ruby installation mechanism while Rbenv does not.

Where are RubyGems stored?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.

What is RubyGems How does it work?

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.


2 Answers

So after 1 1/2 days of torture, reading through at least 50 posts, and installing RVM, Ruby and Rails multiple times, I am finally able to use Rails in my RVM install.

This was the last series of events that I did after installing RVM and Ruby the last time and then it worked:

I removed these from .gemrc so back up your file if you do this:

  • gemhome: /home/[user]/ruby/gems
  • gempath: []
  • --remote

then use

rvm use 1.9.3 --default

then

gem install rails

It seems the trick was:

  1. Change the .gemrc file.
  2. Do not create and use a gemset (rvm use 1.9.3@rails3) before installing Rails.
like image 133
Chris Simeone Avatar answered Oct 26 '22 20:10

Chris Simeone


Make sure you're always 'using' your Ruby version. (Ugh. RVM can be so annoying).

rvm use 1.9.3 --default

Also what does your .gemrc look like? I had to take out --user from mine.

like image 32
nnyby Avatar answered Oct 26 '22 19:10

nnyby