How can I remove the ri
and rdoc
of installed gems? Thanks
3 Answers
You can simply remove the doc
directory in the RubyGems installation directory.
rm -r `gem env gemdir`/doc
On Mac OS X by default, it's /Library/Ruby/Gems/1.8/doc
.
Keep in mind that there might be several installation directories for RubyGems.
- RubyGems will try to install to your user directory (something like
~/.gem/ruby/1.8/
) if it can't access the normal installation directory (e.g. you installed a gem withoutsudo
). - RVM also installs RubyGems for each Ruby it installs which will contain a
doc
directory containingrdoc
andri
files (e.g.~/.rvm/gems/ruby-1.9.2-preview1/doc
).
This will merely remove existing files, but new ones will come with new installations anyway, unless you use the --no-document
flag for gem install or make it a default.

- 1
- 1

- 1,498
- 1
- 11
- 10
-
7`--no-ri --no-rdoc` has been deprecated in favor of `--no-document`, but this answer works the best. – bayendor Jul 06 '14 at 13:10
It worked for me when I tried this:
gem rdoc <gem name> --no-ri --overwrite
Then you can remove only ri of the gem, and leave the gem itself. I don't see we need any other way around for this.

- 5,252
- 3
- 34
- 36
-
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/12968780) – CinCout Jul 12 '16 at 12:05
-
Do you think I didn't understand the question? The question was "How can I remove the ri and rdoc of installed gems?" :) – kangkyu Jul 12 '16 at 18:53
-
You asked the OP to *try* something, which sounds like a guess, and hence a comment. If you are sure of what you are writing in your answer, I don't see why you'll use such words. – CinCout Jul 13 '16 at 05:19
I just had this problem to, after thinking it would be a good idea to have some local rdoc for the train etc, I completely filled up my disc!
So, I bit the bullet, and did it (the hard way).
First, this is how I got in this stupid predicament :-
$ gem install rdoc-data
$ rdoc-data --install
$ gem rdoc --all --overwrite
To undo this, I thought I'd uninstall the gems, and then install them as needed (but without rdoc!)
Get list :-
$ gem list *** LOCAL GEMS *** aasm (2.1.1) actionmailer (3.2.3, 3.2.2, 3.1.4, 3.1.3, 3.1.1, 3.1.0, 2.3.8, 2.3.5) actionpack (3.2.3, 3.2.2, 3.1.4, 3.1.3, 3.1.1, 3.1.0, 2.3.8, 2.3.5) active_support (3.0.0) ... +100 ...
Copy and search/replace
\(.*\)
with '\'Bulk uninstall :-
$ gem uninstall actionmailer \ actionpack \ active_support \ ... 100 more ... ZenTest \ -a -x -I
Watch as the disc gains GB's of free space! (~11GB!)
Twas a stupid idea in the first place, and my solution may be just as much so, but it worked.

- 20,211
- 13
- 59
- 79