How to fix slow gem installs

If you’ve ever run gem install, you know how long it can take to complete. Trust me, you’re not alone: plenty of examples showcase similar frustrations in dealing with slow gem install.

Most larger Ruby projects comes with extensive documentation (awesome! 👍), unfortunately the process of turning RDoc into HTML and ri can be quite time-consuming - especially on larger projects or slower machines.

Fortunately, it’s possible to turn off ri and rdoc processing on gem install by executing the command with flags --no-ri and --no-rdoc:

$ gem install rails --no-rdoc --no-ri

Now keep in mind that RDoc and ri is actually pretty cool and if you use them often, instead of online documentation, then you might want to skip this.

If you want this as your default behavior add this to your ~/.gemrc file:

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

Another option is to create a Shell alias for gem install that in addition also prefixes with sudo to avoid those pesky “You don’t have write permissions …“:

# Alias
$ alias gemi=”sudo gem install –no-ri –no-rdoc”

# Usage
$ gemi rails