开发者

How do you remove the documentation installed by gem install?

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 w开发者_如何学运维ay to safely remove the documentation from my computer? Also, is there a way to configure ruby to not install documentation by default?


run this command:

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

on windows if you use cygwin


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.


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.


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' ...


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜