损坏的红宝石宝石系统 [英] Corrupted ruby gem system
问题描述
$ sudo gem update
我得到:
错误:执行gem时(Gem :: Exception)
/home/sawa/.gem/specs/api.rubygems.org%443/specs.4.8中的spec缓存文件无效
我删除了 .gem
,并重新安装了Ruby ,但问题仍然存在。如何修复此问题?
首先,我建议您保存您的宝石列表,以防万一:
$ gem list> gems.txt
验证您是否使用SPEC CACHE,您认为自己是: p>
$ gem env | grepSPEC CACHE
- SPEC CACHE DIRECTORY:/home/sawa/.gem/specs
<
$ gem来源
/ pre>
如果您想要小心,可以逐个删除源代码,然后重新添加。 (请参阅下面的代码)
尽量保持原始状态,但可能会失败:
$ gem pristine --all
严酷的方法是删除所有gem规格:
rm -rf /home/sawa/.gem/specs
核方法是删除您已经尝试过的gem目录:
rm -rf /home/sawa/.gem
我最好的猜测是你的一个宝石来源正在返回一个不正确的文件,可能是一个暂时的问题。您可以通过移除您所有的宝石来源来解决这个问题。
$ gem sources - -clear-all#清除缓存,但不会删除源
$ gem sources --update#可能会起作用,在这种情况下,您现在可以停止。
如果清除源代码不起作用,那么您可以删除所有代码并重新添加:
$宝石来源
$宝石来源--remove http://gems.rubyforge.org/
$宝石来源--remove http://gems.github.com
...等...
$宝石来源 - - 更新#应该工作正常,因为没有来源
$ gem sources --add http://gems.rubyforge.org/
$ gem sources --update
$ gem sources --add http://gems.github.com
$宝石来源 - 更新
...等...
Somehow, my ruby gems got corrupted, and when I do
$ sudo gem update
I get:
ERROR: While executing gem ... (Gem::Exception) Invalid spec cache file in /home/sawa/.gem/specs/api.rubygems.org%443/specs.4.8
I removed
.gem
, and reinstalled Ruby, but the problem persists. How can I repair this?解决方案First I suggest you save your gem list, just in case:
$ gem list > gems.txt
To verify that you're using the SPEC CACHE that you think you are:
$ gem env | grep "SPEC CACHE" - SPEC CACHE DIRECTORY: /home/sawa/.gem/specs
To see if you have any outdated sources:
$ gem sources
If you want to be careful, you can remove sources one by one, then re-add. (See code below)
Try pristine, though it will likely fail:
$ gem pristine --all
The harsh approach is to delete all the gem specs:
rm -rf /home/sawa/.gem/specs
The nuclear approach is to delete the gem directory, which you write that you've already tried:
rm -rf /home/sawa/.gem
My best guess is that one of your gem sources is returning an incorrect file, possibly a temporary problem. You can figure this out by removing all your gem sources.
$ 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.
If clearing the sources doesn't work, then you can remove all and re-add:
$ 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...
这篇关于损坏的红宝石宝石系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!