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

jzig picture jzig · Jun 10, 2013 · Viewed 9.6k times · Source

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.

Answer

Perhentian picture Perhentian · Jun 26, 2013

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:

And all is now working.

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