Invalid spec cache file

前提是你 提交于 2019-12-10 17:15:20

问题


I have ruby 2.0.0p247 [x64-mingw32] with Gem 2.2.2 installed on Windows 8. I have a persistent problem gem that is making it virtually unusable. Whenever I try to install a new gem, I invariably get:

ERROR: While executing gem ... Invalid spec cache file in C:/Users/...

In the past, I've been able to run gem update or gem update --system and that would clear up the problem for one, single gem install. Subsequent install would fail with the same error. Now even gem update fails with that error message.

I've tried deleting the users/.../.gem directory. When I do that, gem update recreates that directory and promptly fails with the same error message.

I re-installed ruby 1.9.8 with gems several times to try to cure the problem, then upgraded to ruby 2.0.0. Throughout all re-installs and upgrades, the problem persisted.

I'm at my wits end here. Can anyone help me resolve this issue?

Here's the backtrace on the edit"

L:\xampp\htdocs\frameworks\yii2\framework>gem update --backtrace
Updating installed gems
ERROR:  While executing gem ... (Gem::Exception)
    Invalid spec cache file in C:/Users/Larry/.gem/specs/rubygems.org%443/specs.4.8
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:187:in `rescue in load_specs'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:179:in `load_specs'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:266:in `tuples_for'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:228:in `block in available_specs'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each_source'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:222:in `available_specs'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:102:in `search_for_dependency'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:113:in `fetch_remote_gems'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:135:in `highest_remote_version'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:264:in `block in which_to_update'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `each'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `which_to_update'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:96:in `execute'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:167:in `process_args'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:137:in `run'
        C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:54:in `run'
        C:/Ruby200-x64/bin/gem:21:in `<main>'

回答1:


I had the same problem, but was able to fix it this way:

Delete the folder in users/%user%/.gem/ and rerun the command gem sources --update

Hope this helps.



来源:https://stackoverflow.com/questions/22690978/invalid-spec-cache-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!