Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libxml2 missing for nokogiri gem on Windows 8 x64 with Ruby 1.9.3

What I found searching for similar issues was that Nokogiri does not yet have x64 support with Ruby 2.0. However although I'm on a Windows x64 machine my Ruby version is ruby 1.9.3p392 (2013-02-22) [i386-mingw32] from railsinstaller.org (with Rails 3.2.13). This also means DevKit is already installed.

gem install nokogiri --pre gives this error:

    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
    checking for libxml/parser.h... no
    -----
    libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokog
    iri.html for help with installing dependencies.
    -----
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers.  Check the mkmf.log file for more
    details.  You may need configuration options.

    Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/RailsInstaller/Ruby1.9.3/bin/ruby
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib=${xml2-dir}/lib

While gem install nokogiri --pre -- --with-xml2-lib --with-xslt-lib --platform=ruby raises this error:

    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-xml2-lib --wi
    th-xslt-lib --platform=ruby
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers.  Check the mkmf.log file for more
    details.  You may need configuration options.

    Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/RailsInstaller/Ruby1.9.3/bin/ruby
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib=${xml2-dir}/lib

    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:1544:in `dir_config': undefin
    ed method `split' for true:TrueClass (NoMethodError)
    from extconf.rb:147:in `<main>'

I was unable to find a specific solution to any of this via SO/google groups/blogs/etc, is there one?

Here's my path:

    PATH=C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby1.9.3\bin;C:\windows;C:\win
    dows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files(
    x86)\Git\cmd;C:\Program Files\nodejs\;C:\cygwin\bin;C:\mingw64\x86_64-w64-mingw3
    2\bin;C:\mingw64\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\gi
    t\cmd;C:\Users\Joshua\AppData\Roaming\npm;C:\mingw64\x86_64-w64-mingw32\bin;C:\P
    rogram Files\PostgreSQL\9.2\bin;

I have also tried downloading libxml2 from http://linux.softpedia.com/progDownload/libxml2-Download-162.html and placing the contents inside C:\RailsInstaller\Ruby1.9.3\lib as well as C:\RailsInstaller\DevKit\lib but I have received the same errors.

tl;dr there seem to be two different errors depending on the options I pass. The parser.h error and the TrueClass 'split' error.

like image 924
jzig Avatar asked Jun 09 '13 22:06

jzig


People also ask

Where is libxml2 located?

If you find any file or directory with the substring libxml2 in /usr/local/include or /usr/local/lib (such as /usr/local/lib/libxml2.so ) then it is already installed.

What is Nokogiri gem?

The Nokogiri gem is an incredible open-source tool that parses HTML and XML data. It is one of the most widely used gems available, and it can really take your Ruby app to another level for data with its ability to help you intuitively scrape websites.


1 Answers

I had a similar frustration, but I did just remove Ruby 2.0, and the DevKit that I had installed to keep things simple.

I then:

  • Installed 1.9.3
    (http://rubyforge.org/frs/download.php/76952/rubyinstaller-1.9.3-p429.exe)
  • DevKit (DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe)

And all is now working.

Do make sure you go through all the checks at: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

like image 63
Perhentian Avatar answered Sep 19 '22 11:09

Perhentian