Remove unnecessary temporary files after gem install nokogiri [duplicate]

馋奶兔 提交于 2019-12-23 03:26:23

问题


I have to use nokogiri for some xml processing. For this I create a rvm gemset specific to the project and install nokogiri by gem install nokogiri. No problems this far.

But when I look into ~.rvm/gems/ruby-...@nokogiri/gems/nokogiri-.../ext/nokogiri/ and its subfolders I see files worth of 140MB in the filesystem.

Is there some generic way of removing this cruft?


回答1:


That's slightly larger than what I get. I see 108MB on OS X, with the major offenders being 88MB in ext, 18MB in ports, 750k in test and 520k in lib.

In ext/nokogiri you certainly don't need the 87MB of tmp directory. So that's a major savings right there.

phrogz$ pwd
/Users/phrogz/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.6.1

phrogz$ du -sh .
 108M     .

phrogz$ rm -rf ext/tmp
phrogz$ du -sh .
 21M     .

Then again, you also don't need any of the source, header, or compiled files in there, either:

phrogz$ cd ext/nokogiri/
phrogz$ rm *.c *.h *.o
phrogz$ cd ../../
phrogz$ du -sh .
 20M     .

I'm pretty sure you don't need the ports/archives directory, which contains the .tar.gz source of libxml2 and libxslt:

phrogz$ rm -rf ports/archives/
phrogz$ du -sh .
 12M     .

And then there's a few megs of documentation for the libraries you can remove for sure:

phrogz$ rm -rf ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0/share/doc/
phrogz$ rm -rf ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0/share/gtk-doc/
phrogz$ rm -rf ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26/share/doc/
phrogz$ du -sh .
 4.4M     .

You could probably pare it down further, removing things like the test directory. But now you've made a huge dent in the problem.



来源:https://stackoverflow.com/questions/22319146/remove-unnecessary-temporary-files-after-gem-install-nokogiri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!