不知何故,我的红宝石宝石被腐蚀了,当我这么做的时候
$sudo gem update
我明白了:
ERROR: While executing gem ... (Gem::Exception) Invalid spec cache file in /home/sawa/.gem/specs/api.rubygems.org%443/specs.4.8
我删除了.gem,并重新安装了Ruby,但问题仍然存在.我该怎么修呢?
解决方法
首先,我建议您保存您的宝石列表,以防万一:
$gem list > gems.txt
要验证您使用的是您认为自己的SPEC CACHE:
$gem env | grep "SPEC CACHE" - SPEC CACHE DIRECTORY: /home/sawa/.gem/specs
要查看您是否有任何过时的来源:
$gem sources
如果您要小心,可以逐个删除源,然后重新添加. (见下面的代码)
尝试pristine,虽然它可能会失败:
$gem pristine --all
rm -rf /home/sawa/.gem/specs
rm -rf /home/sawa/.gem
我最好的猜测是你的一个宝石源正在返回一个不正确的文件,可能是一个临时问题.您可以通过删除所有宝石来源来解决这个问题.
$gem sources --clear-all # clears the cache,but doesn't remove the source $gem sources --update # probably will work,in which case you can stop now.
$gem sources $gem sources --remove http://gems.rubyforge.org/ $gem sources --remove http://gems.github.com ...etc ... $gem sources --update # should work fine,because there are no sources $gem sources --add http://gems.rubyforge.org/ $gem sources --update $gem sources --add http://gems.github.com $gem sources --update ...etc...