14

There are a lot of answers for this question that work under older versions of rubygems, but what is the recommended procedure for Rubygems 1.8.x? I have an /etc/gemrc file that looks like this:

gem: --no-rdoc --no-ri

These options seem to be ignored during any gem install.

Update:

After doing some more digging, it seems the problem is related to rvm which partitions not just the various versions of ruby, but their associated configuration files, too. To check where the config file should go, use irb:

require 'rubygems'
Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
# => "/opt/local/rvm/rubies/ruby-1.9.2-p180/etc/gemrc"
Community
  • 1
  • 1
tadman
  • 208,517
  • 23
  • 234
  • 262

3 Answers3

12

You need to put the following in your ~/.gemrc or /etc/gemrc file

install: --no-rdoc --no-ri
Pan Thomakos
  • 34,082
  • 9
  • 88
  • 85
  • Wait, what? `/etc/.gemrc`? Still doesn't work for me even with that highly irregular name. – tadman Jun 02 '11 at 20:03
  • It does work if in `~/.gemrc` but I was trying to avoid that. – tadman Jun 02 '11 at 20:06
  • In [the source](https://github.com/rubygems/rubygems/blob/master/lib/rubygems/config_file.rb) it seems to refer to `/etc/gemrc`, generally, but `rvm` causes confusion. Updated my question with notes. – tadman Jun 02 '11 at 20:08
  • Hi, I updated my post to refer to /etc/gemrc - mistyped that second . in the original post. The main point is that the command should be 'install: ...' not 'gem: ...' – Pan Thomakos Jun 02 '11 at 20:17
  • 1
    With regards to RVM you will definitely find /etc/gemrc of little use and ~/.gemrc will be more useful. RVM is really meant to partition your ruby installations and configurations - as you point out in your update the SYSTEM_WIDE_CONFIG_FILE is located in an entirely new directory. – Pan Thomakos Jun 02 '11 at 20:18
1

It appears that this is dependent on where Ruby--and by extension gem--is installed in general, not just with RVM. I installed Ruby from source. The default install location when your are building from source is /usr/local/bin, so I installed Ruby there. Naturally this installs gem and all the other tools that come with Ruby in the same directory as well. I had my gemrc under /etc, but it didn't start working until I moved it to /usr/local/etc instead.

I later re-installed Ruby under /usr/bin instead /usr/local/bin and got the same result. It is now looking for gemrc under /usr/etc instead of /usr/local/etc. The gem tool must be looking for a path relative to where it's installed like ../etc when searching for the system-wide gemrc file.

Adam
  • 1,755
  • 20
  • 31
0

I have the identical file but it's in ~/.gemrc and it works for me on RubyGems 1.8.5. I'm using RVM/Ruby 1.9.2 if that makes any difference.

Gregory Brown
  • 1,380
  • 9
  • 15