14

我在搜索类似问题时发现Nokogiri尚不支持Ruby 2.0的 x64 支持。但是,虽然我在Windows x64机器上,但我的 Ruby 版本是来自 railsinstaller.org (with 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 install 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/progDownload/libxml2-Download-162.html下载 libxml2并将内容放入 C:\RailsInstaller\Ruby1.9.3\lib 以及 C:\RailsInstaller\DevKit \lib 但我收到了同样的错误。

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

4

4 回答 4

6

我也有类似的挫败感,但我只是删除了 Ruby 2.0,以及我为保持简单而安装的 DevKit。

我然后:

现在一切正常。

请确保您通过以下所有检查: https ://github.com/oneclick/rubyinstaller/wiki/Development-Kit

于 2013-06-26T11:08:16.390 回答
6

以下是如何使用 Chocolatey 和 DevKit x64 为 Windows 8.1 x64 安装 Nokogiri。

https://stackoverflow.com/a/22210252/148844

cinst libxml2
cinst libxslt
cinst libiconv

gem install nokogiri --with-xml2-include=C:\Chocolatey\lib\libxml2.2.7.8.7\build\native\include --with-xml2-lib=C:\Chocolatey\lib\libxml2.redist。 2.7.8.7\build\native\bin\v110\x64\Release\dynamic\cdecl --with-iconv-include=C:\Chocolatey\lib\libiconv.1.14.0.11\build\native\include --with-iconv -lib=C:\Chocolatey\lib\libiconv.redist.1.14.0.11\build\native\bin\v110\x64\Release\dynamic\cdecl --with-xslt-include=C:\Chocolatey\lib\libxslt. 1.1.28.0\build\native\include --with-xslt-lib=C:\Chocolatey\lib\libxslt.redist.1.1.28.0\build\native\bin\v110\x64\Release\dynamic

于 2014-03-05T22:03:36.013 回答
5

@Steve - 有一个新版本的 nokogiri (1.6.2)支持 x64 Ruby(这在 Win7 x64 Ruby 200 上对我有用)。在撰写本文时,它处于预发布状态,请使用以下命令安装:

 gem install nokogiri --prerelease
于 2014-05-02T21:14:37.633 回答
4

我自己也遇到了这个问题,看起来 Nokogiri 不支持 64 位 Ruby:https ://github.com/sparklemotion/nokogiri/issues/864解决方案似乎是使用 32 位 Ruby,或者等到他们支持 64 位 Ruby .

更新:更新以反映来自@magiccrafter 的评论,即现在应该支持 64 位 Ruby。

于 2013-07-25T09:58:30.160 回答