2

Whether I use gem install or bundle install for my gems, they don't work. Sometimes sudo gem install gets gems to work. I ran the gem list -d and which gem commands, and it seems that my system is configured such that all the gems get installed into " /Library/Ruby/Gems/1.8" but my environment expects them in "/usr/bin/gem". How could I properly correct this? I was under the impression that 'bundle' should be able to install a local, application specific copy of a gem?

Kirill
  • 3,667
  • 4
  • 30
  • 35

2 Answers2

12

Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.

If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/lzap/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/lzap/.gem/ruby/1.9.3
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

You can even change this with GEM_HOME environment variable. Happy gemming!

lzap
  • 16,417
  • 12
  • 71
  • 108
4

I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.

arogachev
  • 33,150
  • 7
  • 114
  • 117
Pan Thomakos
  • 34,082
  • 9
  • 88
  • 85
  • 1
    +1 for RVM. The OP needs to read the installation section, and make sure everything is completed - too many people only do it part way. And, once RVM is installed, never use `sudo` for installing any gems for a RVM-controlled Ruby or bad things will happen. – the Tin Man Feb 06 '11 at 03:44
  • If that is the only reasonable options, then according to RVM instructions I am supposed to find ".bash_profile" and add something to it. Where do I find the said file? – Kirill Feb 06 '11 at 04:12
  • It's located in your home directory (~/.bash_profile) if it doesn't exist, feel free to create it. – Pan Thomakos Feb 06 '11 at 04:18
  • Got'ya! I was searching for a file that didn't exist. thanks! – Kirill Feb 06 '11 at 04:31
  • You can use either `~/.bash_profile` or `~/.bashrc`, but you don't need to use both. – the Tin Man Feb 06 '11 at 04:38
  • I followed the instructions on the RVM website, but the results haven't changed. RVM is working, but 'which ruby' still points to /urs/bin/ruby. bummer – Kirill Feb 08 '11 at 00:42
  • Have you tried running the rvm 1.9.2 command for example? Does that change your ruby version? – Pan Thomakos Feb 08 '11 at 00:49
  • Somehow I was able to fix this and get RVM to run. I think I should have been more careful about following instructions :) – Kirill Feb 17 '11 at 01:10