2012-09-29 34 views
12

Cố gắng cài đặt nokogiri trên Mountain Lion. Tôi đã sử dụng ruby ​​1.8.7 nhưng chỉ nâng cấp lên 1.9.3 nhưng nó đã ngừng cài đặt gói từ khi hoạt động.Cài đặt nokogiri Mac OS X 10.8.2 XCode được cài đặt

Ngẫu nhiên, tôi có thể giải quyết vấn đề này bằng cách gỡ cài đặt ruby ​​1.9.3 và hoàn nguyên về 1.8.7. tuy nhiên điều này rõ ràng là một giải pháp tối ưu vì tôi không muốn bị mắc kẹt trên 1.8.7 cho phần còn lại của thời gian ...

Users-MacBook-Pro:sample_app user$ ls 
Gemfile  app  doc  script 
Gemfile.lock config  lib  spec 
README.md config.ru log  tmp 
Rakefile db  public  vendor 
Ravins-MacBook-Pro:sample_app user$ bundle 
Fetching gem metadata from https://rubygems.org/....... 
/Users/user/.rvm/gems/[email protected]/gems/bundler-1.2.1/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
Using rake (0.9.2.2) 
Using i18n (0.6.1) 
Using multi_json (1.3.6) 
Using activesupport (3.2.8) 
Using builder (3.0.3) 
Using activemodel (3.2.8) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.8) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.8) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Using activerecord (3.2.8) 
Using activeresource (3.2.8) 
Using addressable (2.3.2) 
Installing nokogiri (1.5.5) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
checking for libxml/parser.h... *** 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=/Users/user/.rvm/rubies/ruby-1.9.3-p194/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 
/Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
    from extconf.rb:114:in `<main>' 


Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection. 
Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out 
An error occurred while installing nokogiri (1.5.5), and Bundler cannot continue. 
Make sure that `gem install nokogiri -v '1.5.5'` succeeds before bundling. 

Tôi đã tải Xcode bao gồm các công cụ phát triển, vì vậy tôi không biết tại sao nó sẽ không cài đặt nokogiri ...

Khi tôi cố gắng để cài đặt nokogiri trực tiếp, tôi nhận được:

ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

     /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
checking for libxml/parser.h... *** 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=/Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/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 
/Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
    from extconf.rb:114:in `<main>' 


Gem files will remain installed in /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection. 
Results logged to /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out 

developer tools components tab cảm ơn,

developer tools install photo

+0

Tôi giả sử bạn cũng có kết quả tương tự khi cố gắng cài đặt nokogiri ngay bên ngoài bu ndle? –

+0

Tôi vừa thêm thông báo lỗi tôi nhận được khi cố gắng cài đặt nokogiri trực tiếp vào câu trả lời – Ravin

+1

@ravin nó không phải là vấn đề của các công cụ dòng lệnh .. –

Trả lời

30

Sau khi nghiên cứu ngắn tôi tìm hiểu những gì vấn đề có thể chỉ cần giải quyết bằng cách tạo liên kết tượng trưng

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 

công trình đối với tôi hy vọng cho bạn quá

gem install nokogiri 
Building native extensions. This could take a while... 
ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

     /Users/morozovm/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb 
checking for libxml/parser.h... *** extconf.rb failed *** 

bash-3.2$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 
Password: 
bash-3.2$ gem install nokogiri 
Building native extensions. This could take a while... 
Successfully installed nokogiri-1.5.6 
1 gem installed 
+1

Nó cũng làm việc cho tôi. Tôi biết đó là loại vấn đề này nhưng nghiêm túc ... Làm thế nào để mất thời gian của bạn ... – Nazka

+1

Hoàn hảo. Đã làm cho tôi. Đã có vấn đề khi nâng cấp Xcode lên phiên bản 5 (Rails 4, Ruby 2.0.0-p195) – Ari53nN3o

-3

Tôi nghĩ rằng đây là bit quan trọng nhất của thông báo lỗi:

warning: Insecure world writable dir /usr/local in PATH, mode 040777 

Một số phần của quá trình xây dựng đang rên rỉ rằng thư mục đó có quyền truy cập như vậy mà bất cứ ai có thể viết thư cho nó. Bạn có thể cố gắng săn lùng nó - hoặc bạn có thể sửa nó.

+1

Không hề. Điều đó hoàn toàn nằm ngoài ngữ cảnh .. –

1

Hãy thử các tính năng này. Tôi phải đối mặt với cùng một vấn đề và nó đã làm việc cho tôi. Trước tiên cài đặt libxml2 và sau đó chạy lại bundler.

brew install libxml2 
brew link libxml2 

Nguồn: http://decielo.com/articles/11/rails-3-on-lion-hey-ho-lets-go

Cập nhật:

Tôi hy vọng rằng bạn đã homebrew cài đặt. Nếu bạn không có homebrew thì tôi sẽ đề nghị bạn cài đặt homebrew và sau đó cài đặt libxml2 và sau đó bundler. Không sử dụng cổng mac trong trường hợp bạn không có homebrew.

Cập nhật:

Nó không phải là một vấn đề của các công cụ dòng lệnh. Nó không thành công tại libxml. Cố gắng đọc lỗi và bạn sẽ thấy

checking for libxml/parser.h... *** extconf.rb failed *** 

Và đó là vấn đề

+2

Đáng buồn là điều này đã không giúp tôi (tôi có một vấn đề giống hệt nhau). Tôi đã liên kết 'libxml2' và' libxslt' nhưng tôi vẫn nhận được 'libxml/parser.h' @Ravin đã có ở trên. Bất kỳ đề xuất nào khác? –

+0

U nhận được lỗi tương tự? kiểm tra cho libxml/parser.h ... *** extconf.rb không thành công *** –

Các vấn đề liên quan