代码之家  ›  专栏  ›  技术社区  ›  Ricardo Acras

如何使--no ri--no rdoc成为gem安装的默认值?

  •  989
  • Ricardo Acras  · 技术社区  · 16 年前

    我不使用安装在我的机器或我处理的服务器中的gems的ri或rdoc输出(我使用其他文档方法)。

    我安装的每个gem默认情况下都会安装ri和rdoc文档,因为我忘记了设置 --no-ri --no-rdoc .

    有没有办法让这两个标志成为默认标志?

    12 回复  |  直到 8 年前
        1
  •  1144
  •   the Tin Man    10 年前

    您只需在本地添加以下行 ~/.gemrc 文件(在您的 文件夹)

    gem: --no-document
    

    或者可以将此行添加到全局gemrc配置文件中。以下是如何找到它(在Linux中)

    strace gem source 2>&1 | grep gemrc
    
        2
  •  482
  •   BryanH Philipp Andreychev    9 年前

    RVM’s documentation 以下内容:

    只需将此行添加到 ~/.gemrc /etc/gemrc :

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

    注: 最初的答案是:

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

    这不再有效;RVM文档已更新,因此当前的答案仅包括 gem 指令是正确的。

        3
  •  171
  •   James Lim    12 年前

    注意 --no-ri --no-rdoc 根据新的 guides . 建议的方法是使用 --no-document 在里面 ~/.gemrc /etc/gemrc .

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

    gem: --no-document
    
        4
  •  76
  •   kaiz.net    11 年前

    在Linux(可能还有Mac)上:

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

    这一行曾经出现在这里的评论中,但不知何故消失了。

        5
  •  43
  •   Daniel X Moore mcdon    13 年前

    #/主页/用户/.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
  •  32
  •   Brad Larson    12 年前

    在Windows XP上,.gemrc文件的路径是

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

    这个文件不是默认创建的,您应该自己创建。

        7
  •  15
  •   skywinder Grady Player    8 年前

    适用于Windows 7用户的OneLiner:

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

        8
  •  11
  •   Vincent Robert    16 年前

    可以使用指定默认选项 .gemrc 配置文件。

    Documentation about gem configuration file

        9
  •  6
  •   Andreas    13 年前

    循序渐进:

    要从终端创建/编辑.gemrc文件,请执行以下操作:

    vi  ~/.gemrc
    

    您将打开一个名为vi的编辑器。 粘贴:

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

    单击“Esc”按钮。

    键入:

    :exit
    

    您可以使用以下命令检查一切是否正确:

    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.gemrc
    
        10
  •  6
  •   Community CDub    8 年前

    如上所述,放置 gem: --no-document 在你的gem文件中。然而,整个系统的GEMRC并不一定总是 /etc/gemrc . 如果您使用的是RVM,或者在下面安装了Ruby /usr/local/bin 它需要去一个不同的地方。您可以通过运行 irb 打字…

    require 'rubygems'
    Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
    

    看这上面的原始帖子 here .

        11
  •  4
  •   peter    11 年前

    在Windows7中,不存在.gemrc文件,您可以让Ruby创建这样的文件(在Explorer中这样做不容易)。

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

    你必须确认(它不安全)。 现在,该文件在用户配置文件文件夹(C:\users\)中创建。

    可以编辑文本文件以删除添加的源,也可以使用

    gem sources --remove http://rubygems.org
    
        12
  •  1
  •   Rajkaran Mishra    8 年前

    对于Windows用户,Ruby不设置.gemrc文件。所以您必须在主目录中创建.gemrc文件( echo %USERPROFILE% )并在其中加入以下行:

    gem: --no-document
    

    正如前面的答案中已经提到的,不要使用——没有ri和——没有rdoc,这会导致它被否决。自己看看:

    gem help install
    
    推荐文章