Computer >> Computer tutorials >  >> Programming >> ruby

How to globally disable rdoc and ri during gem installs

Gem installs can be slooow. One of the biggest culprits is documentation. Every time you install a gem, your computer has to scan the source of that gem and generate documentation.

This can be useful if you often need to check gem documentation when you're offline. Just run  gem server and point your browser at https://localhost:8808 to access them. The ri command is also handy to search documentation from the terminal.

But if you're like me, you probably don't use local docs. You probably have a decent internet connection at most times. So the time spent generating documentation is just time wasted.

If you're using bundler to install all of your gems, you don't have to do anything. Bundler skips rdoc/ri by default. If you happen to be using the gem command directly, you'll need to do a bit of configuration.

You may already know that you can disable rdoc/ri generation when you run gem install, by passing in certain flags.

gem install honeybadger --no-rdoc --no-ri  # The old, deprecated way
gem install honeybadger --no-document      # The new way

You can also tell rubygems to apply these flags as defaults. Just add the following line to your ~/.gemrc file:

gem: --no-document

But what if you're planning a camping trip and need to grab the local documentation? It's no problem to generate it yourself.

gem rdoc --all --overwrite # regen all docs
gem rdoc honeybadger # generate docs for one gem

Be careful if you choose to regen all your docs, though. It might take a while. :)