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

Asked

Viewed 265 times

8

Always when giving 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 that?

4 answers

15


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

gem: --no-ri --no-rdoc
  • 1

    you can also use gem: --no-document

3

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

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

With that the shortcut gi [gem] becomes available.

0

Go to the terminal and type:

$ which gem

This will tell you which directory the Gem executable is in. Open it with an editor. It will probably 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 assignment args = ARGV.clone to concatenate the command line arguments with the --no-ri and the --no-rdoc.

I haven’t tested this solution but I believe it works.

  • Changing scripts directly should only be done as the last alternative... In addition to opening space for bugs, you still risk losing the change in the next gem update.

0

There is a file called gemrc where it is possible to specify the default. You can put so ~/.gemrc how much in the /etc/gemrc (this path may vary from distro to distro) the following line:

gem: --no-document

Browser other questions tagged

You are not signed in. Login or sign up in order to post.