Damaged Ruby System

Somehow my ruby ​​jewels were damaged 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 uninstalled .gemand reinstalled Ruby, but the problem persists. How can i fix this?

+3
source share
1 answer

First, I suggest you keep a list of gems just in case:

$ gem list > gems.txt

To make sure you are using SPEC CACHE, what you think:

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

To find out if you have outdated sources:

$ gem sources

If you want to be careful, you can delete sources one at a time, and then add them again. (See code below)

Try the original ones, although this most likely will fail:

$ gem pristine --all

A harsh approach is to remove all gem specifications:

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

, gem, , :

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...
+5

Source: https://habr.com/ru/post/1533752/


All Articles