无法在Windows中安装Nokogiri for Ruby

时间:2013-06-24 16:56:10

标签: ruby windows nokogiri devkit

我知道这很简单,但我无法理解。我需要在Ruby中运行一个脚本,它需要Nokogiri。我确实有一些其他语言的经验,但不是Ruby。

这是我的系统:

  

Ruby 2.0.0-p195(x64)安装在@ C:\ Programs \ RubyLanguage

     

Ruby开发工具包(mingw64-64-4.7.2-20130224-1432)安装在@ C:\ Programs \ RubyDevKit

当我运行gem install nokogiri时,我收到此错误:

    ERROR:  Error installing nokogiri:
        The 'nokogiri' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

够容易。所以我跟着the link of above并执行了第3步。但是第4步说生成“config.yml”。所以我做了。现在该文件是一个带有一些注释的空列表。我仍然无法安装Nokogiri,因为上面的错误,我似乎没有得到任何DevKit。我的意思是开发套件安装中的步骤对我来说不够清楚。


更新它现在说Nokogiri的安装失败了(DevKit Works根据步骤5:安装json-1.8.0的文档 已安装1个宝石)

mkmf.log: package configuration for libxslt is not found
package configuration for libxml-2.0 is not found
package configuration for libiconv is not found
find_header: checking for libxml/parser.h... -------------------- no

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Programs/RubyLanguage/include/ruby-2.0.0/x64-mingw32 -IC:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/backward -IC:/Programs/RubyLanguage/include/ruby-2.0.0 -I. -IC:/Programs/RubyLanguage/include/libxml2 -IC:/Programs/RubyLanguage/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -LC:/Programs/RubyLanguage/lib -LC:/Programs/RubyLanguage/lib -L.      -lx64-msvcrt-ruby200  -lshell32 -lws2_32 -limagehlp -lshlwapi   "
In file included from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/defines.h:153:0,
                 from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:70,
                 from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby.h:33,
                 from conftest.c:1:
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w32_pow':
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/win32.h:776:16: warning: conversion to 'double' from 'long double' may alter its value [-Wconversion]
In file included from C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby.h:33:0,
                 from conftest.c:1:
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_float_value':
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:777:6: warning: negative integer implicitly converted to unsigned type [-Wsign-conversion]
C:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/ruby.h:777:6: warning: negative integer implicitly converted to unsigned type [-Wsign-conversion]
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"x86_64-w64-mingw32-gcc -E -IC:/Programs/RubyLanguage/include/ruby-2.0.0/x64-mingw32 -IC:/Programs/RubyLanguage/include/ruby-2.0.0/ruby/backward -IC:/Programs/RubyLanguage/include/ruby-2.0.0 -I. -IC:/Programs/RubyLanguage/include/libxml2 -IC:/Programs/RubyLanguage/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline  conftest.c -o conftest.i"
conftest.c:5:27: fatal error: libxml/parser.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <libxml/parser.h>
/* end */

CMD日志

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\SEPEHR>gem install nokogiri
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:/Programs/RubyLanguage/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:/Programs/RubyLanguage/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
        --without-xml2-lib=${xml2-dir}/lib
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib
        --with-libxslt-config
        --without-libxslt-config
        --with-pkg-config
        --without-pkg-config
        --with-libxml-2.0-config
        --without-libxml-2.0-config
        --with-pkg-config
        --without-pkg-config
        --with-libiconv-config
        --without-libiconv-config
        --with-pkg-config
        --without-pkg-config


Gem files will remain installed in C:/Programs/RubyLanguage/lib/ruby/gems/2.0.0/
gems/nokogiri-1.6.0 for inspection.
Results logged to C:/Programs/RubyLanguage/lib/ruby/gems/2.0.0/gems/nokogiri-1.6
.0/ext/nokogiri/gem_make.out

3 个答案:

答案 0 :(得分:13)

更新:从版本1.6.2开始,Nokogiri现在支持支持64位版本的Ruby 2.0.0。 (请注意,它需要libxml&gt; = 2.6.21)

如果由于某种原因仍需要安装x86版本,或者如果您想了解如何使用DevKit安装和构建gem,那么这就是答案:


Nokogiri尚不支持 64位版本的Ruby 2.0.0。您可以阅读它和follow the status here

但Nokogiri 确实支持ruby 2.0.0的 x86 版本。您应该能够在2.0.0 x86安装上安装gem。

手动安装非常简单。我更喜欢RailsInstaller,因为我需要维护其他东西。方法如下:

  1. 下载并解压缩所需版本的文件。对于x86版本的2.0.0,请务必download the correct version of DevKit

  2. 修复路径:确保您的路径包含右侧ruby,gem和DevKit目录的目录: 假设您将x86版本的ruby 2.0.0安装到C:\rubies\ruby-2-0-0-x86中,并将相关的DevKit安装到C:\rubies\DevKit-xxxx-x86中,您需要在PATH中包含这些目录:

    C:\红宝石\红宝石2-0-0 86 \ BIN C:\红宝石\红宝石2-0-0-X86 \ LIB \红宝石\宝石\ 2.0.0 C:\红宝石\的devkit-XXXX-86 \ bin中

  3. 将DevKit注入正确的ruby安装:一旦安装了ruby并在键入ruby -v时可以获得正确的信息,然后运行ruby dk.rb init - 这将获得DevKit设置和放大器; '注入'正确的红宝石版本。 (注意,我总是要编辑生成的config.yml文件,并将其放入我想要的ruby安装的正确路径中。如果需要,请不要冒汗。)

答案 1 :(得分:0)

是的......降级到1.9.3有效。 Tnx寻求帮助。我把摘要放在这里:

  • 安装Ruby 1.9.3(不要将安装名称更改为ex.RubyLang或
    配置无法自动找到它

  • 安装DevKit(遵循DevKit安装步骤)

  • 安装Nokogiri

答案 2 :(得分:0)

我无法在Windows 7上为Ruby 2.0安装x64 Nokogiri,但binary gem似乎正在运行。