2013-06-24 36 views
5

Tôi biết điều này rất đơn giản nhưng tôi không thể hiểu được. Tôi cần phải chạy một kịch bản trong Ruby và nó đòi hỏi Nokogiri. Tôi có một số kinh nghiệm trong các ngôn ngữ khác nhưng không có trong Ruby.Không thể cài đặt Nokogiri cho Ruby trong Windows

Đây là hệ thống của tôi:

Ruby 2.0.0-p195 (x64) is installed @C:\Programs\RubyLanguage

Ruby Development Kit (mingw64-64-4.7.2-20130224-1432) is installed @C:\Programs\RubyDevKit

Khi tôi chạy gem install nokogiri tôi nhận được lỗi này:

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' 

Dễ dàng đủ. Vì vậy, tôi theo sau the link of above và đã làm bước 3. Tuy nhiên bước 4 nói tạo "config.yml". Tôi cũng vậy. Bây giờ các tập tin là một danh sách trống với một số ý kiến. Tôi vẫn không thể cài đặt Nokogiri vì lỗi ở trên và tôi dường như không nhận được bất cứ nơi nào với DevKit. Điều tôi đang nói là các bước trong quá trình cài đặt Bộ công cụ phát triển không đủ rõ ràng đối với tôi.


Cập nhật nó bây giờ nói lắp đặt Nokogiri thất bại (devkit Làm việc theo bước 5: Cài đặt tài liệu cho json-1.8.0 1 viên ngọc cài đặt)

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 đăng nhập

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 
+0

Bạn hoàn toàn _need_ DevKit được cài đặt để làm việc với Nokogiri trên cửa sổ (trừ khi bạn tình cờ có các công cụ biên dịch khác được cài đặt, điều này dường như không phải là trường hợp). Bạn có thể tìm thấy hướng dẫn tại đây (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit). Chính xác những gì không làm việc cho bạn với cài đặt DevKit? – PinnyM

+0

Tôi khuyên bạn nên sử dụng ruby ​​1.9.3, 2.0 trên cửa sổ là một đề xuất dicey tại thời điểm này – pguardiario

Trả lời

13

cập nhật: Tính đến phiên bản 1.6.2, Nokogiri tại hiện hỗ trợ phiên bản 64 bit của Ruby 2.0.0. (Lưu ý rằng nó đòi hỏi libxml> = 2.6.21)

Dưới đây là câu trả lời nếu bạn vẫn cần phải cài đặt phiên bản x86 vì một lý do hoặc nếu bạn muốn hiểu làm thế nào để cài đặt và xây dựng một viên ngọc bằng devkit:


Nokogiri chưa hỗ trợ 64-bit phiên bản Ruby 2.0.0. Bạn có thể đọc về nó và follow the status here.

Nhưng Nokogiri hiện hỗ trợ x86 phiên bản ruby ​​2.0.0. Bạn sẽ có thể cài đặt gem trong phiên bản 2.0.0 x86.

Thật dễ dàng để cài đặt thủ công. Tôi thích điều đó hơn RailsInstaller bởi vì tôi cần phải duy trì những thứ khác như chúng.Dưới đây là cách thực hiện:

  1. Tải xuống và giải nén tệp cho phiên bản bạn cần. Đảm bảo download the correct version of DevKit cho phiên bản x86 2.0.0.

  2. Fix đường dẫn của bạn: Hãy chắc chắn rằng con đường của bạn bao gồm các thư mục với ruby, dirs đá quý, và devkit phải: Giả sử bạn cài đặt phiên bản x86 của ruby ​​2.0.0 vào C:\rubies\ruby-2-0-0-x86 và devkit gắn vào C:\rubies\DevKit-xxxx-x86 bạn sẽ cần để bao gồm các thư mục này trong PATH của bạn:

    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. Tiêm DevKit vào đúng cài đặt Ruby: Khi bạn đã cài đặt ruby ​​và có thể lấy thông tin chính xác khi bạn nhập ruby -v, sau đó chạy ruby dk.rb init - sẽ được DevKit thiết lập & 'được tiêm' vào phiên bản chính xác của ruby. (NB Tôi luôn luôn phải chỉnh sửa config.yml tập tin đó được sản xuất và đưa vào đúng đường dẫn để cài đặt ruby ​​tôi muốn. Đừng đổ mồ hôi nó nếu bạn cần phải làm điều đó.)

0

Yup ... Hạ cấp xuống 1.9.3 đã hoạt động. Tnx để được giúp đỡ. Tôi đặt tóm tắt ở đây:

  • Cài đặt của Ruby 1.9.3 (Không thay đổi cài đặt Tên để ex.RubyLang hoặc
    cấu hình không thấy nó tự động)

  • Install devkit (theo devkit Lắp đặt bước)

  • Install Nokogiri

0

tôi đã không có thể cài đặt x64 Nokogiri cho Ruby 2.0 trên Windows 7, nhưng binary gem dường như đang hoạt động.