无法在 Windows 中安装 Nokogiri for Ruby

2024-02-14

我知道这很简单,但我就是想不通。我需要在 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'

很容易。所以我跟着上面的链接 http://github.com/oneclick/rubyinstaller/wiki/Development-Kit并执行了步骤 3。但是步骤 4 说生成“config.yml”。所以我做了。现在该文件是一个带有一些注释的空列表。由于上述错误,我仍然无法安装 Nokogiri,而且我似乎对 DevKit 没有任何进展。我想说的是,开发套件安装的步骤对我来说还不够清楚。


Update现在显示 Nokogiri 安装失败( DevKit 根据步骤 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 log

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

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

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


Nokogiri does not yet support the 64-bit version of Ruby 2.0.0. You can read about it and follow the status here https://github.com/sparklemotion/nokogiri/issues/864.

但野科切does支持x86红宝石2.0.0版本。您应该能够在 2.0.0 x86 安装中安装 gem。

手动安装非常容易。与 RailsInstaller 相比,我更喜欢它,因为我需要保持其他东西的原样。就是这样:

  1. 下载并解压您需要的版本的文件。务必下载正确版本的 DevKit http://rubyinstaller.org/downloads/对于 2.0.0 的 x86 版本。

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

    C:\rubies\ruby-2-0-0-x86\bin C:\rubies\ruby-2-0-0-x86\lib\ruby\gems\2.0.0 C:\rubies\DevKit-xxxx-x86\bin

  3. 将 DevKit 注入正确的 ruby​​ 安装中:安装 ruby​​ 后,您可以在键入时获得正确的信息ruby -v,然后运行ruby dk.rb init-- 这将设置 DevKit 并将其“注入”到正确的 ruby​​ 版本中。 (注意:我总是必须编辑config.yml生成的文件并将其放入我想要的 ruby​​ 安装的正确路径中。如果您需要这样做,请不要担心。)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 Windows 中安装 Nokogiri for Ruby 的相关文章

  • 默认更新嵌套属性

    我尝试更新 iProduction 这是生产中的嵌套表单 但此行出现参数错误 参数数量错误 0 代表 1 生产 update iproducts attributes cow id cow 我的创作动作制作 def create produ
  • Ruby 在特定目录中运行 shell 命令

    我知道如何在 Ruby 中运行 shell 命令 例如 x cmd 但是 如何指定运行此命令的目录 有没有类似的脱壳方式 类似subprocess Popen在Python中 subprocess Popen r c mytool tool
  • 如何在Windows 7中使用批处理脚本获取本地连接名称

    我正在编写一个简单的批处理脚本来检索 Windows 上的所有网络接口 但我只需要本地连接名称 本地连接接口名称不是默认名称 有没有办法使用批处理脚本仅检索本地连接名称作为字符串 不完全确定您在问什么 但我认为您的问题是您想要获取网络接口的
  • 使用 mysql2 gem 获取最后插入的 id

    我有这样的代码 require mysql2 db query insert into clients Name values client 我可以通过 1 个查询返回最后插入的 ID 吗 您可以使用last id客户端实例的方法 clie
  • 有没有一种好方法来计算 ruby​​ 中范围元素的总和

    计算范围总和的好方法是什么 Input 4 10 Output 4 5 6 7 8 9 10 49 您可以使用EnumerableRange 对象上的方法 在本例中使用Enumerable inject 4 10 inject gt 49
  • ruby 1.9.1 的 gem install mongrel 失败

    昨天我开始了 Rails 开发 我安装了 ruby 1 9 1 rubygems 和 Rails 跑步gem install mongrel工作得很好 表面上也安装了杂种 我有点困惑 因为 script server 默认启动 webric
  • 在 Rails 中强制内联渲染 PDF 文档

    我正在编写一个从一组 XML 文件生成 PDF 文件的服务 正在正确生成 PDF 但是 每次我单击 查看 PDF 链接时 浏览器都会要求用户下载 PDF 文件 我需要 PDF 内联显示 就像任何常规 HTML 页面一样 我虽然我写的代码是正
  • 使用搜索词打开 Windows 资源管理器查找窗格

    我正在尝试创建一个应用程序 该应用程序打开 Windows 资源管理器搜索功能并搜索输入了指定术语的文件 文件夹 我已经有了 Windows Vista SP1 使用 Windows 索引服务引入的 search query 命令的代码 这
  • 使用 Linq to XML 将 XElement 添加到 XML 文件

    使用 Linq to XML 我尝试将 XElement 添加到现有 XML 文件 它必须在 Windows Phone NET 框架中完成 目前我的 XML 文件如下所示
  • 如何从 Ruby 模块中仅导入几个函数?

    假设我有一个带有以下方法的模块 function1 function2 function3 我想导入 function1 和 function2 但不导入 function3 有没有办法在红宝石中做到这一点 不确定是否有一种干净的方法来添加
  • 如何仅回显“开”或“关”文本?

    大家都知道 在 Windows 命令文件中 cmd echo on echo off 启用和禁用回显 但是如何仅回显文本 on 或文本 off IE 如何发送文本 on off to stdout 目标系统 Windows XP 那么在 D
  • 这个结果背后的逻辑是什么?

    def foo override end p foo bye bye p foo hello world Output override hello 我可以理解如果结果是 override world or even bye bye hel
  • 为什么安装 Ruby 1.9.3 时会出现 404 错误?

    我最近擦除了我的计算机 操作系统 Mac OS X 10 6 8 并重新安装了所有开发工具 我再次安装了RVM 但是 它不允许我安装 Ruby 1 9 3 到目前为止我已经尝试过 rvm install 1 9 3 rvm install
  • 无法打开 Python。错误 0xc000007b

    我最近一直在学习 Python 3 我在我的上网本 32 位 Windows 7 上创建简单的小程序没有任何问题 当我将它安装在我的上网本上时 我没有遇到任何问题 但现在我已经开始使用它了 我想将它安装在我的台式机上 并且我有一个 我的桌面
  • 在 Rails 中,我可以通过委托方法订购查询吗?

    我在通过委托方法订购查询时遇到困难 我的任务是帮助将一个相当大的 Rails 3 应用程序升级到 Rails 4 我在索引操作中遇到了这个查询 我知道这些对象的命名是可怕且令人困惑的 measurements controller rb d
  • Jekyll 站点仅在推送到 GitHub 时才会失败

    我正在使用 Jekyll 开发一个新版本的静态网站 该网站通过 Github 页面部署 https devcampy com https devcampy com 存储库 https github com gianarb devcampy
  • 使用 tweetstream 守护进程写入数据库

    我正在尝试将与关键字匹配的所有推文写入我的数据库 我在中设置了以下内容tracker rb require rubygems require tweetstream TweetStream Daemon new Bill Gates mon
  • 批处理文件 - 读取特定行,并将该行中的特定字符串保存为变量

    有没有办法让 for f 循环 或其他任何东西 读取特定行 这是我到目前为止的代码 它读取每一行的第一个单词 echo off set file readtest txt for f tokens 1 delims A in file do
  • 从外部 gem 增强模型

    我在用着炼油厂CMS http refinerycms com 在我们的网站上让较少的技术人员更新内容 在 gem 内部 它们有一个 Page 类 用于映射站点上的每个顶级页面 我想在这个 Page 类上使用acts as taggable
  • ruby 包含问题

    class Foo def initialize a puts Hello a end end module Bar def initialize b puts b World end end class Sample lt Foo inc

随机推荐