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

2019-01-02 18:58发布

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?

标签: ruby rubygems
12条回答
伤终究还是伤i
2楼-- · 2019-01-02 19:20

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

gem: --no-document

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
查看更多
后来的你喜欢了谁
3楼-- · 2019-01-02 19:20

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
查看更多
无与为乐者.
4楼-- · 2019-01-02 19:21

From RVM’s documentation:

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

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

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.

查看更多
弹指情弦暗扣
5楼-- · 2019-01-02 19:23

# /home/{user}/.gemrc

---
:update_sources: true
:sources:
- http://gems.rubyforge.org/
- http://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/

查看更多
余生无你
6楼-- · 2019-01-02 19:24

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
查看更多
情到深处是孤独
7楼-- · 2019-01-02 19:25

On Linux (and probably Mac):

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

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

查看更多
登录 后发表回答