简体   繁体   English

无法安装spree gem - 错误:无效的gem:包已损坏

[英]Cannot install spree gem - ERROR: invalid gem: package is corrupt

I'm trying to install the Spree gem, but it's giving me this error: 我正在尝试安装Spree gem,但它给了我这个错误:

 gem install spree
Fetching: httparty-0.13.3.gem (100%)
When you HTTParty, you must party hard!
Successfully installed httparty-0.13.3
Fetching: highline-1.6.21.gem (100%)
Successfully installed highline-1.6.21
Fetching: friendly_id-5.0.4.gem (100%)
Successfully installed friendly_id-5.0.4
Fetching: font-awesome-rails-4.2.0.0.gem (100%)
Successfully installed font-awesome-rails-4.2.0.0
Fetching: ffaker-1.25.0.gem (100%)
Successfully installed ffaker-1.25.0
Fetching: polyglot-0.3.5.gem (100%)
Successfully installed polyglot-0.3.5
Fetching: colorize-0.7.3.gem (100%)
Successfully installed colorize-0.7.3
ERROR:  Error installing spree:
    invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /home/tarek/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/cache/nokogiri-1.6.4.1.gem

I tried to uninstall and reinstall Nokogir again, with the same result. 我尝试再次卸载并重新安装Nokogir,结果相同。

When I tried sudo gem install nokogiri another error happened: 当我尝试sudo gem install nokogiri发生了另一个错误:

ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:4:in `<main>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.6.4.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.6.4.1/ext/nokogiri/gem_make.out

I think RubyGems didn't download the file properly. 我认为RubyGems没有正确下载文件。 So, the system is reporting that the gem is corrupt. 因此,系统报告宝石已损坏。 Delete /home/tarek/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/cache/nokogiri-1.6.4.1.gem and then install the gem again. 删除/home/tarek/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/cache/nokogiri-1.6.4.1.gem然后再次安装gem。

$ sudo rm /home/tarek/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/cache/nokogiri-1.6.4.1.gem

$ gem install nokogiri

Please make sure you install the following command: 请确保安装以下命令:

sudo apt-get install libxslt-dev libxml2-dev

Now try installing Nokogiri. 现在尝试安装Nokogiri。 Be aware of sudo if you using RVM. 如果您使用RVM,请注意sudo

sudo gem install nokogiri

Hope my answer would be helpful. 希望我的回答会有所帮助。

Thanks. 谢谢。

Looks like you have the system Ruby installed. 看起来你已经安装了系统Ruby。

You need to first do: 你需要先做:

$ sudo apt-get install ruby-dev

and then do: 然后做:

$ sudo gem install nokogiri

I'd encourage you to use Ruby Version Manager like RVM or rbenv for managing Ruby environments instead of using the system Ruby on your development environment. 我鼓励您使用Ruby Version Manager(如RVMrbenv)来管理Ruby环境,而不是在开发环境中使用Ruby系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM