安装 gem 时出错 [英] Error installing gems
问题描述
我在安装某些 gem 时遇到错误.我正在使用 ubuntu 10.10.错误消息显示了这一点.
I am getting an error when installing certain gems. I am using ubuntu 10.10. The error messages shows this.
ERROR: While executing gem ... (NoMethodError)
undefined method `spec' for nil:NilClass
推荐答案
我遇到了与此完全相同的错误...
I had exactly the same error as this...
在安装 Rails 3 时,我的计算机断电了.重新启动计算机并继续安装 Rails 3 后,该过程失败并出现完全相同的错误.问题是由于 gem 安装缓存已损坏/空 gem 文件.我的解决方案是清除此缓存并再次运行安装,如下所示:
While installing Rails 3 my computer suffered a power outage. After restarting the computer and continuing the Rails 3 installation the process failed with this exact same error. The problem was due to the gem install cache which had corrupted / empty gem files. My solution was to clear this cache and run the install again, as follows:
- 使用
gem env
找出缓存的位置 - 列出该缓存中的所有宝石,例如
ls -l/usr/lib/ruby/gems/1.8/cache/
- 使用
gem list
与成功安装的 gem 进行比较 - 从缓存列表中删除宝石列表中缺少的宝石,例如使用
rm
- 我还必须从规范目录中删除一些空的/损坏的 gemspec 文件
ls -l/usr/lib/ruby/gems/1.8/specifications/
- 继续安装,例如
sudo gem install -v=3.0.6 rails --no-rdoc --no-ri
希望这对在 gem 安装过程中遇到停电或其他外部故障的其他人有所帮助!
Hope this helps someone else who has a power outage or other external failure during a gem install process!
这篇关于安装 gem 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!