Windows 8 x64和Ruby 1.9.3上的nokogiri gem缺少libxml2 [英] libxml2 missing for nokogiri gem on Windows 8 x64 with Ruby 1.9.3

查看:102
本文介绍了Windows 8 x64和Ruby 1.9.3上的nokogiri gem缺少libxml2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在搜索类似问题时发现, Nokogiri 尚不支持 Ruby 2.0 的x64支持.但是,尽管我使用的是 Windows x64 计算机,但我的Ruby版本是railsinstaller.org(含Rails 3.2.13)的 ruby​​ 1.9.3p392(2013-02-22)[i386-mingw32] ).这也意味着 DevKit 已安装.

gem install nokogiri --pre 出现此错误:

    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

gem安装nokogiri --pre---with-xml2-lib --with-xslt-lib --platform = ruby​​ 时,会出现此错误:

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

我无法通过SO/google groups/blogs/etc找到具体的解决方案,有吗?

这是我的路线:

    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;

我还尝试了从 http://linux.softpedia.com下载libxml2 /progDownload/libxml2-Download-162.html 并将内容放置在C:\ RailsInstaller \ Ruby1.9.3 \ lib以及C:\ RailsInstaller \ DevKit \ lib中,但是我收到了相同的错误.

tl; dr似乎有两个不同的错误,具体取决于我通过的选项. parser.h错误和TrueClass'split'错误.

解决方案

@Steve-有一个支持x64 Ruby的nokogiri的新版本(1.6.2)(在Win7 x64 Ruby 200上对我有用).在撰写本文时,请使用:

 gem install nokogiri --prerelease

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.

解决方案

@Steve - There is a new version of nokogiri (1.6.2) that supports x64 Ruby (this worked for me on Win7 x64 Ruby 200). At time of writing it's in pre-release, install using:

 gem install nokogiri --prerelease

这篇关于Windows 8 x64和Ruby 1.9.3上的nokogiri gem缺少libxml2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆