Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing nokogiri in ubuntu 14.0.4 (Ruby 1.8.7)

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

like image 688
Nani Avatar asked Jun 11 '15 12:06

Nani


3 Answers

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

like image 55
zabusa Avatar answered Oct 19 '22 05:10

zabusa


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)
like image 13
Nani Avatar answered Oct 19 '22 04:10

Nani


First, update the package index (package list).

sudo apt-get update 

Install libxml2.

sudo apt-get install libxml2-dev
like image 8
Sachin R Avatar answered Oct 19 '22 03:10

Sachin R