Error installing nokogiri in ubuntu 14.0.4 (Ruby 1.8.7)

11.7k views Asked by At

I'm trying to install the bundle(bundle install) in Ubuntu 14.0.4 installed Ruby 1.8.7.And it fails to install the bundle and displayed the error:

An error occurred while installing nokogiri (1.4.7), and Bundler cannot
continue. Make sure that `gem install nokogiri -v '1.4.7'` succeeds before bundling.

so now I tried to get the nokogiri 1.4.7 with but it got failed showed

$ sudo gem install nokogiri -v '1.4.7'
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

so again I tried to get this libxml2, but end up with the below message:

$ sudo gem install libxml2
ERROR:  Could not find a valid gem 'libxml2' (>= 0) in any repository
ERROR:  Possible alternatives: libxml4r


$ sudo gem install libxml4r
ERROR:  Error installing libxml4r
extconf failure: need libxml2.

I tried with the reference:

$ gem install nokogiri -- --use-system-libraries
$ bundle install

but still the same nokogiri error coming again. Don't have a clue how to continue. please help me!!!!

7

There are 7 answers

0
Nani On BEST ANSWER

I tried the following commands and I've got it. Thanks to Mr.Kumar

$ sudo apt-get update 
$ sudo apt-get install libxml2-dev
$ sudo apt-get install libxslt-dev
$ sudo gem install nokogiri -v '1.4.7'

$ gem list nokogiri
*** LOCAL GEMS ***
nokogiri (1.4.7)
1
Sachin R On

First, update the package index (package list).

sudo apt-get update 

Install libxml2.

sudo apt-get install libxml2-dev
0
Kevin Delord On

On Ubuntu server I also had to install zlib1g-dev:

$ sudo apt-get install zlib1g-dev
0
Akash K Roy On
$ sudo apt-get update
$ sudo apt-get install libxml2-dev
$ sudo gem install nokogiri --version 1.8.0

That will be all.

1
zabusa On

in my case i need to install also this library. $ sudo apt-get install zlib1g-dev

1
David Bendahan On

After doing everything above and still getting the error what worked for me using bundle config build with the system libraries:

bundle config build.nokogiri --use-system-libraries
bundle install

Hope it helps! :)

0
MartinSolie On

I had the same problem on ubuntu 18.04 and running sudo apt-get install ruby-dev helped me.