安装nokogiri的gem devkit(windows)时缺少libxml2

时间:2011-06-23 15:37:42

标签: ruby-on-rails nokogiri libxml2 devkit

我一直在经历这个宝石的很多问题,所以我读到我必须使用de 1.5.0-beta。

由于我正在使用Windows,我下载了DevKit。但是当我跑步时:

gem install nokogiri --pre --withwith xml2-lib --with-xslt-lib

我明白了:

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:/Ruby187/bin/ruby.exe extconf.rb --with-xml2-lib --with-xslt-lib --pla
taform=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:/Ruby187/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:/Ruby187/lib/ruby/1.8/mkmf.rb:1177:in `dir_config': private method `split' cal
led for true:TrueClass (NoMethodError)
        from extconf.rb:87


Gem files will remain installed in C:/Ruby187/lib/ruby/gems/1.8/gems/nokogiri-1.
5.0.beta.4 for inspection.
Results logged to C:/Ruby187/lib/ruby/gems/1.8/gems/nokogiri-1.5.0.beta.4/ext/no
kogiri/gem_make.out

我该怎么办?

1 个答案:

答案 0 :(得分:1)

使用类似

的命令
gem install nokogiri --pre -- --with-xml2-lib --with-xslt-lib

看起来你正在尝试安装最新版本的nokogiri。尝试使用--version指定精确版本。

另请注意nokogiri 1.6 +

的以下要求
  • 红宝石1.9.3或更高
  • 在Nokogiri 1.6.0及更高版本中,libxml2和libxslt不再是要求

所以,如果你确实想使用ruby 1.8.7(这是EOL,顺便说一句)那么,是的,你需要指定nokogiri< 1.6。但是,如果你可以使用现代的生活红宝石,那么你可能会躲避lib依赖。