How to set --no-ri --no-rdoc as default when using gem install?

8

Always giving the gem install I have to provide the parameters --no-ri and --no-rdoc, I would like this to be standard for this command!

How can I do this?

    
asked by anonymous 13.12.2013 / 13:31

4 answers

15

You can add a .gemrc file to your home, with the options you want to pass to all gem commands by default:

gem: --no-ri --no-rdoc
    
13.12.2013 / 13:34
3

A more general alternative to jpkrohling's solution is to define an alias on your terminal. In bash, for example, you can add the following in your .bash_profile file:

alias gi="gem install --no-ri --no-rdoc"

With this the gi [gem] shortcut becomes available.

    
13.12.2013 / 13:37
0

Go to the terminal and type:

$ which gem

This will tell you which directory is the gem executable. Open it with an editor. It's probably going to be something like this:

#!/usr/bin/env ruby
ENV['GEM_HOME']=ENV['GEM_HOME'] || '/Users/Ecil/.rvm/gems/ruby-2.0.0-rc1'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '/Users/Ecil/.rvm/gems/ruby-2.0.0-rc1:/Users/Ecil/.rvm/gems/ruby-2.0.0-rc1@global'
ENV['PATH']='/Users/Ecil/.rvm/gems/ruby-2.0.0-rc1/bin:/Users/Ecil/.rvm/gems/ruby-2.0.0-rc1@global/bin:/Users/Ecil/.rvm/rubies/ruby-2.0.0-rc1/bin:' + ENV['PATH']

#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++

require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'

required_version = Gem::Requirement.new ">= 1.8.7"

unless required_version.satisfied_by? Gem.ruby_version then
  abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
end

args = ARGV.clone

begin
  Gem::GemRunner.new.run args
rescue Gem::SystemExitException => e
  exit e.exit_code
end

Modify the args = ARGV.clone assignment to concatenate the command line arguments with --no-ri and --no-rdoc .

I have not tested this solution but I believe it works.

    
13.12.2013 / 13:38
0

There is a file named gemrc where you can specify the default. You can therefore not ~/.gemrc as /etc/gemrc (this path may vary from distro to distro) the following line:

gem: --no-document

    
29.01.2014 / 20:56