Rails installation Invalid gem : package is Corrupt-nokogiri

I was trying to install rails in ubuntu 14.04, but I am getting the
following error.

$gem install rails
ERROR: Error installing rails:
invalid gem: package is corrupt, exception while verifying:
undefined method `size’ for nil:NilClass (NoMethodError) in
/home/usr/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/cache/nokogiri-1.6.7.1.gem

Please Help with this.
Thank You.

Hi @vigneshwaran sivalingam

Please check the version of ruby installed in your ubuntu. ( ruby -v)

Sometimes it may happen that some package file does not install while
installing ubuntu.

you can follow the steps from the below link
Install Ruby on Rails – Railsinstaller.org - or follow this link
Install Ruby on Rails In Ubuntu 14.04 Using RVM - YouTube

Regards

On Tue, Jan 12, 2016 at 11:49 PM, vigneshwaran sivalingam <

On 12 January 2016 at 18:19, vigneshwaran sivalingam
[email protected] wrote:

I was trying to install rails in ubuntu 14.04, but I am getting the
following error.

$gem install rails
ERROR: Error installing rails:
invalid gem: package is corrupt, exception while verifying: undefined
method `size’ for nil:NilClass (NoMethodError) in
/home/usr/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/cache/nokogiri-1.6.7.1.gem

I advise using rvm for installing ruby and rails. Others prefer rbenv.
sudo apt install curl
gpg --keyserver hkp://keys.gnupg.net --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --rails

The above should install the dependencies, rvm, ruby and rails.
See https://rvm.io

Colin

Thank you.

Hi colin, I tried what you said, It reinstalled the ruby then rails, but
when it downloaded the nokogiri1.6.7.0.gem, it showed error. But anyway
rails was installed. When i checked the version it shows
~$ rails -v
Ignoring executable-hooks-1.3.2 because its extensions are not built.
Try:
gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built. Try:
gem
pristine gem-wrappers --version 1.2.7
Ignoring nokogiri-1.6.7.1 because its extensions are not built. Try:
gem
pristine nokogiri --version 1.6.7.1
Rails 4.2.5

On Jan 13, 2016, at 6:35 AM, vigneshwaran sivalingam [email protected] wrote:

Hi colin, I tried what you said, It reinstalled the ruby then rails, but when it
downloaded the nokogiri1.6.7.0.gem, it showed error. But anyway rails was
installed. When i checked the version it shows
~$ rails -v
Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem
pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built. Try: gem
pristine gem-wrappers --version 1.2.7
Ignoring nokogiri-1.6.7.1 because its extensions are not built. Try: gem
pristine nokogiri --version 1.6.7.1
Rails 4.2.5

You may want to ask on the Nokogiri mailing list
([email protected]) – they are very good (and quick) about
installation problems. Also, as Colin mentioned, rvm can make things
very straightforward for you, not least because it does a ton of work to
make sure your build environment is “sane” before it tries to install
anything. If you can’t build Nokogiri on a *nix machine, then there is
very likely something funny with your compiler or system libraries, and
rvm will tell you about that, down to which Debian package to use or
which source to compile or which Homebrew package to install to get it
working. Current and recent versions of Nokogiri bundle all the
dependencies (time was you needed a working libxml of a certain vintage
to make it go) but you still need a working compiler and link tool.

Walter

Thank you so much for your guidance Walter.

On Wednesday, January 13, 2016 at 6:26:04 PM UTC+5:30, Walter Lee D.

I ran into same issues and for me the resolution was very simple.

Just remove the cached gem file for the gem and try reinstalling.

Example in above case it should be “rm /home/usr/.rbenv/versions/2.2.
3/lib/ruby/gems/2.2.0/cache/nokogiri-1.6.7.1.gem”

Thanks.

regards,
Sur