How do you remove the documentation installed by gem install?
Asked Answered
S

6

28

I know it's possible to install a gem without the documentation, but unfortunately, I didn't for the first three months I used ruby. In that time, I managed to install a significant amount of gems, but not once since I started using ruby have I used the documentation on my computer. I always look to docs on the internet.

What is the best way to safely remove the documentation from my computer? Also, is there a way to configure ruby to not install documentation by default?

Selfimportant answered 29/11, 2009 at 11:21 Comment(0)
R
12

Gem documentation is installed in [RUBY]/lib/ruby/gems/doc, where [RUBY] is the directory into which you installed Ruby (C:/ruby on my machine).

I don't see why you shouldn't just delete the folders representing the gems for which don't don't need documentation: you can always regenerate it.

Ribose answered 29/11, 2009 at 11:45 Comment(0)
D
63

run this command:

rm -r "$(gem env gemdir)"/doc/*

on windows if you use cygwin

Dupin answered 19/4, 2012 at 14:38 Comment(0)
R
12

Gem documentation is installed in [RUBY]/lib/ruby/gems/doc, where [RUBY] is the directory into which you installed Ruby (C:/ruby on my machine).

I don't see why you shouldn't just delete the folders representing the gems for which don't don't need documentation: you can always regenerate it.

Ribose answered 29/11, 2009 at 11:45 Comment(0)
P
7

I understand there is a .gemrc file that may be used.

install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

puts the two lines in it. I believe you put the .gemrc file in your $Home directory.

Phasis answered 18/8, 2012 at 3:19 Comment(0)
V
6

Copy & paste any of these into a Bourne-compatible shell:

Remove existing docs for locally-installed gems, current-user only

(exec 1>&2; DIR="$(gem env gemdir)"; \
DOCDIR="$DIR"/doc; \
if [ -d "$DOCDIR" ]; then \
  echo "Contents of '$DOCDIR': "; ls "$DOCDIR"/; echo ''; \
  read -p "Do you really want to remove contents of RubyGems doc dir '$DOCDIR' ? [Yn] " ANS; \
  if [ "$ANS" = y ] || [ "$ANS" = Y ]; then \
    rm -rf "$DOCDIR"/*; \
  fi; \
fi)

Remove docs for all globally installed system gems

(exec 1>&2; for DIR in $(gem env path | tr ':' '\n'); do \
  DOCDIR="$DIR"/doc; \
  if [ -d "$DOCDIR" ]; then \
    echo "Contents of '$DOCDIR': "; ls "$DOCDIR"/; echo ''; \
    echo '!! Possibly removes system-provided gem docs, review carefully before continuing  ("n" if unsure or Ctrl-C to abort completely) !!'; \
    read -p "Do you really want to remove RubyGems doc dir '$DOCDIR' ? [Yn] " ANS; \
    if [ "$ANS" = y ] || [ "$ANS" = Y ]; then \
      sudo rm -rf "$DOCDIR"/*; \
    fi; \
  fi; \
done)

Prevent current user from generating gems docs from now onwards

with modern RubyGems:

(X='gem: --no-document'; \
touch ~/.gemrc && \
grep -q "^$X$" ~/.gemrc || echo "$X" >> ~/.gemrc)

with old RubyGems: X='gem: --no-ri --no-rdoc' ...

Vasyuta answered 17/11, 2015 at 6:9 Comment(0)
M
4

I can't answer the first part of your problem (I have the same issue myself) but I have managed to not install documentation by default.

You can specify some default command line options in the gem config file, you can specify not to generate documentation (something like --no-rdoc and --no-ri).

Sam

Mecklenburg answered 29/11, 2009 at 11:32 Comment(0)
D
2

This command worked for me in removing documentation installed by install.

rm -r "$(gem env gemdir)"/doc/*

Here's another way to go about it;

To locate the folder where gems are installed on your system, simply run the following on terminal or shell

gem env home

This will display an output like

/home/username/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0

You can then locate the docs folder and delete all the documentations that you find there for each gem in a ruby version

I also want to add this too to the answers provided,

if want to prevent gems from generating documentation during installation, then turn off local documentation generation by creating a file called ~/.gemrc which contains a configuration setting to turn off this feature:

Simply run this code in your terminal or shell

printf "install: --no-rdoc --no-ri\nupdate:  --no-rdoc --no-ri\n" >> ~/.gemrc

OR

echo "gem: --no-document" > ~/.gemrc

This will prevent gems from generating documentation during installation, saving you the stress of deleting/removing gem documentations on your system later.

That's all

I hope this helps.

Denten answered 2/8, 2019 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.