简体   繁体   中英

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:

 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.

When I tried sudo gem install nokogiri another error happened:

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

$ 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. Be aware of sudo if you using RVM.

sudo gem install nokogiri

Hope my answer would be helpful.

Thanks.

Looks like you have the system Ruby installed.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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