Can't install Nokogiri gem, "libxml/parser.h" not found, but its there, why?
Asked Answered
H

2

16

I tried to install Nokogiri but I always get an compiling error:

checking for libxml/parser.h... *** extconf.rb failed ***

but, I've installed it and all other dependencies.

I try to give the installer hints like this:

%> gem install nokogiri -- --with-xml2-lib=/usr/lib/ --with-xml2-include=/usr/include/libxml2/

...

checking for libxml/parser.h... *** extconf.rb failed ***

...

but it still doesn't install:

%> find /usr/include/ -name "parser.h"    
/usr/include/libxml2/libxml/parser.h
...

I'm on Ubuntu 11.10.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Output of:

"dpkg-query -l | grep xml" and "dpkg-query -l | grep xslt"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The failure seem to be on the side of GCC:

%> cat hello.c
#include <stdio.h>

main()
{
   printf("Hello World \n");
}

%> gcc hello.c
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
collect2: ld gab 1 als Ende-Status zurück
Hitch answered 6/3, 2012 at 18:54 Comment(6)
It would be helpful to know what operating system this is.Stope
Trying a different approach - you should have an mkmf.log file from the directory where the install failed. Can you show us the contents of that file? Also - do you have the build tools and compilers installed on your system? extconf.rb might be attempting to do test building. Try to run something like gcc or make from the command line, see if they respond.Cold
I think you truly don't have them installed. Did you install them using sudo apt-get install libxml2-dev libxslt-dev?Stope
Hmm, I ran into similar issue on Mac OSX today for nokogiri 1.5.2Manriquez
Looks like the libraries are not correct for the architecture. Could you run: 1. which gcc, 2.dpkg-query -S "crt1.o"|grep "/crt1.o". Are you on x64?Zymogenesis
This question should be re-opened. I had this issue using ubuntu 13.04 on an Amazon ec2 instance. I think a large number of people could be helped by this question as I was.Scuttlebutt
J
22

This will work.

sudo apt-get install libxslt-dev libxml2-dev
gem install nokogiri
Juratory answered 11/9, 2012 at 16:45 Comment(2)
might have to uninstall nokogirl and/or libxml-ruby first ala: gem uninstall nokogiri; gem uninstall libxml-ruby; then reinstallDagny
I keep getting this error and having to use this solution everytime I try to run a Rails 3 app.Dendrology
C
2

I just faced the same issue on (cat /etc/centos-release:) CentOS release 6.6 (Final).

sudo yum install -y rubygem-nokogiri

…fixed that problem.

(see: http://www.nokogiri.org/tutorials/installing_nokogiri.html#red_hat___centos)

Carmina answered 13/4, 2015 at 11:49 Comment(1)
I got away with yum install libxml2-devel libxslt-devel (on CentOS 6.7). I don't have the system Ruby installed, so this saves me having to install a bunch of Ruby-related dependencies.Necessary

© 2022 - 2024 — McMap. All rights reserved.