损坏的红宝石系统

损坏的红宝石系统

本文介绍了损坏的红宝石系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故,我的红宝石被损坏了,当我这样做时

Somehow, my ruby gems got corrupted, and when I do

$ 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,但问题仍然存在.我该如何修复它?

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

验证您使用的是您认为的 SPEC CACHE:

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

核心方法是删除你写的已经尝试过的gem目录:

The nuclear approach is to delete the gem directory, which you write that you've already tried:

rm -rf /home/sawa/.gem

我的最佳猜测是您的一个 gem 源返回了一个不正确的文件,这可能是一个临时问题.您可以通过删除所有 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...

这篇关于损坏的红宝石系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 15:57