Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 792
Tarek Saied Avatar asked Feb 28 '26 10:02

Tarek Saied


2 Answers

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
like image 165
Tarique Avatar answered Mar 03 '26 02:03

Tarique


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.

like image 39
Rubyrider Avatar answered Mar 03 '26 00:03

Rubyrider