2015-02-09 120 views
3

不知怎的,我的红宝石的宝石被损坏了,当我做损坏红宝石宝石系统

$ 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,并重新安装红宝石,但问题仍然存在。我该如何修复?

+0

也许尝试删除'〜/ .gem'一次'宝石更新--system' (因为它可能是一个在新的RubyGems中修复的bug)。此外,Ruby版本,RubyGems版本和任何Ruby版本管理器(chruby,rbenv,RVM等)? – 2015-02-09 04:34:53

+0

@AndrewMarshall Ruby是2.2.0,Ruby的宝石是随它一起来的。我直接从源代码编译和安装。 – sawa 2015-02-09 04:57:39

回答

5

首先,我建议你保存你的宝石名单,以防万一:

$ gem list > gems.txt 

要确认您使用的SPEC缓存你以为你是:

$ gem env | grep "SPEC CACHE" 
- SPEC CACHE DIRECTORY: /home/sawa/.gem/specs 

要查看你有任何过时的来源:

$ gem sources 

如果你想要小心,你可以逐个删除源,然后重新一个DD。 (请参见下面的代码)

尝试质朴,虽然它可能会失败:

$ gem pristine --all 

残酷的方法是删除所有的宝石规格:

rm -rf /home/sawa/.gem/specs 

核的方法是删除宝石目录,你写的,你已经尝试过:

rm -rf /home/sawa/.gem 

我最好的猜测是o你的宝石来源的ne返回一个不正确的文件,可能是一个暂时的问题。你可以通过删除所有的宝石来源来解决这个问题。

$ 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... 
+0

我认为'宝石来源 - 清除所有'和'宝石来源 - 更新'做到了。这是答案。谢谢。 – sawa 2015-02-09 05:01:16