Ruby: gem installed in wrong directory

10,645

Solution 1

There are a couple of things that could be wrong:

  1. Your default interpreter is not what you think it is:

Make sure you run: rvm --default use 1.9.2

After this run: ruby -v to make sure you really do have the right ruby as your default ruby. If you do then gem install rails should work fine.

  1. Your ruby interpreter did not install correctly (or RVM itself did not install correctly - unlikely):

It could be that your rvm did not install correctly, although this is unlikely. More likely your ruby interpreter did not install correctly. I suggest uninstalling and then reinstalling, while it installs observe closely for any errors/warnings when compiling and then installing the interpreter and then the gems that RVM installs by default (rake, rubygems). You'll probably see an error in one of these steps which likely means you're missing a library that is needed for ruby or the gems to install properly.

Solution 2

if you want to install rails in the RVM directory you just have to run this :

rvm gem install rails

Share:
10,645
Aion
Author by

Aion

Updated on June 04, 2022

Comments

  • Aion
    Aion almost 2 years

    I am fairly new on Linux(using Ubuntu 10.10). I'm having some problem trying to install Rails 3.0.5 to the correct gem directory.

    I have a root installation of Ruby (1.8.7) which I accidentally installed (which probably had a version of gem along with it) and RVM which I purposefully installed to manage Ruby versions. I am able to default my Ruby version using RVM, no problem.

    But when I attempt to install rails using the command:

    gem install rails
    

    it installs rails on the root gems directory which is: /var/lib/gems/1.8/gems

    but I want to install rails in the RVM directory instead: /.rvm/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/gems

    Some how, even after doing sudo apt-get purge ruby rubygems. The bad gem is still there. I determine that by doing a whereis gem (correct function?). Which returns /usr/bin/gem1.8 /usr/bin/gem /usr/share/man/man1/gem.1.gz

    Now, how do I get rid of the bad gem and install the correct gem within RVM?

    BTW, my GEM_PATH is /home/me/.rvm/gems/ruby-1.9.2-p180@rails3:/home/me/.rvm/gems/ruby-1.9.2-p180@global: which makes this more mysterious.

    Any suggestion is appreciated,

    Thanks :)