Ricardo Acras
Ricardo Acras

Reputation: 36244

How to make --no-ri --no-rdoc the default for gem install?

I don't use the RI or RDoc output from the gems I install in my machine or in the servers I handle (I use other means of documentation).

Every gem I install installs RI and RDoc documentation by default, because I forget to set --no-ri --no-rdoc.

Is there a way to make those two flags the default?

Upvotes: 1095

Views: 283365

Answers (13)

David
David

Reputation: 2008

/home/{user}/.gemrc

---
:update_sources: true
:sources:
- https;//rubygems.org
- https://gems.rubyforge.org/
- https://gems.github.com
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
gem: --no-ri --no-rdoc

http://webonrails.com/2008/12/03/skiping-installation-of-ri-and-rdoc-documentation-while-installing-gems/

Upvotes: 45

avisri
avisri

Reputation: 171

~/.gemrc file

---
gem: --no-document
:update_sources: true
:sources:
- https://rubygems.org/
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true

Use HTTPS and a known source. An improvement over the above answer.

PS: I tried to post the comment and could not get it to format nicely. Finally resorted to posting a new answer.

Upvotes: 1

Jirapong
Jirapong

Reputation: 24256

You just add the following line to your local ~/.gemrc file (it is in your home folder):

gem: --no-document

by

echo 'gem: --no-document' >> ~/.gemrc

or you can add this line to the global gemrc config file.

Here is how to find it (in Linux):

strace gem source 2>&1 | grep gemrc

The --no-document option is documented in the RubyGems CLI Reference.

Upvotes: 1304

gdelfino
gdelfino

Reputation: 11181

From RVM’s documentation:

Just add this line to your ~/.gemrc or /etc/gemrc:

gem: --no-document

Note: The original answer was:

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

This is no longer valid; the RVM docs have since been updated, thus the current answer to only include the gem directive is the correct one.

Upvotes: 507

Gabe
Gabe

Reputation: 495

A oneliner for the windows 7 users:

(echo install: --no-document && echo update: --no-document) >> c:\ProgramData\gemrc

Upvotes: 16

Rajkaran Mishra
Rajkaran Mishra

Reputation: 4942

For Windows users, Ruby doesn't set up .gemrc file. So you have to create .gemrc file in your home directory (echo %USERPROFILE%) and put following line in it:

gem: --no-document

As already mentioned in previous answers, don't use --no-ri and --no-rdoc cause its deprecated. See it yourself:

gem help install

Upvotes: 3

Slava V
Slava V

Reputation: 17256

On Linux (and probably Mac):

echo 'gem: --no-document' >> ~/.gemrc

This one-liner used to be in comments here, but somehow disappeared.

Upvotes: 105

Adam
Adam

Reputation: 1755

As mentioned above, put gem: --no-document in your gem file. However, the system-wide gemrc will not always necessarily go into /etc/gemrc. If you are using RVM, or you have Ruby installed under /usr/local/bin, it needs to go in a different location. You can find this location by running irb and typing...

require 'rubygems'
Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE

See the original post on this over here.

Upvotes: 7

peter
peter

Reputation: 42192

On Windows7 the .gemrc file is not present, you can let Ruby create one like this (it's not easy to do this in explorer).

gem sources --add http://rubygems.org

You will have to confirm (it's unsafe). Now the file is created in your userprofile folder (c:\users\)

You can edit the textfile to remove the source you added or you can remove it with

gem sources --remove http://rubygems.org

Upvotes: 5

James Lim
James Lim

Reputation: 13054

Note that --no-ri and --no-rdoc have been deprecated according to the new guides. The recommended way is to use --no-document in ~/.gemrc or /etc/gemrc.

install: --no-document
update: --no-document

or

gem: --no-document

Upvotes: 190

Viachaslau Tysianchuk
Viachaslau Tysianchuk

Reputation: 1690

On Windows XP the path to the .gemrc file is

c:\Documents and Settings\All Users\Application Data\gemrc 

and this file is not created by default, you should create it yourself.

Upvotes: 33

Andreas
Andreas

Reputation: 2397

Step by steps:

To create/edit the .gemrc file from the terminal:

vi  ~/.gemrc

You will open a editor called vi. paste in:

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

click 'esc'-button.

type in:

:exit

You can check if everything is correct with this command:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.gemrc

Upvotes: 5

Vincent Robert
Vincent Robert

Reputation: 36120

You can specify default options using the .gemrc configuration file.

Documentation about gem configuration file

Upvotes: 10

Related Questions