2014-06-08 20 views
5

Tôi đang cố gắng cài đặt Ruby on Rails qua RVM trên Yosemite. Tất cả mọi thứ dường như đã làm việc, tuy nhiên, khi tôi cố gắng để chạy 'bó cài đặt' Tôi đã trình bày với một lỗi liên quan đến Nokogiri:Cài đặt Nokogiri trên Yosemite

pauls-air:~ paulmcguane$ gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib 
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib' 
This could take a while... 
Building nokogiri using packaged libraries. 
ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

Các thông báo lỗi là:

/Users/paulmcguane/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb 
Building nokogiri using packaged libraries. 
----- 
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.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 
     --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/paulmcguane/.rvm/rubies/ruby-2.1.2/bin/ruby 
     --help 
     --clean 
     --use-system-libraries 
     --enable-static 
     --disable-static 
     --with-zlib-dir 
     --without-zlib-dir 
     --with-zlib-include 
     --without-zlib-include=${zlib-dir}/include 
     --with-zlib-lib 
     --without-zlib-lib=${zlib-dir}/lib 
     --enable-cross-build 
     --disable-cross-build 

extconf failed, exit code 1 
+0

Bạn có lẽ nên để cho nokogiri sử dụng phiên bản đóng gói của xml lib chứ không phải buộc việc sử dụng một trong những bạn đã cài đặt (mặc dù nó trông giống như nó có thể được làm điều đó anyway) Ngoài ra cần phải đề cập đến trong thông báo lỗi của một tập tin đăng nhập với lỗi biên dịch chính xác. –

+1

Chưa được cài đặt trên Yosemite. Nhưng tôi sẽ bắt đầu một lần nữa với điều này với một gemset tươi và chắc chắn rằng Nokogiri được liệt kê trước khi đường ray (hoặc bất kỳ đá quý nào khác). Điều này có thể đảm bảo Nokogiri sử dụng libxml2 nhúng của nó (điều này khiến bạn không gặp vấn đề gì với con đầu tiên). xem thêm https://github.com/sparklemotion/nokogiri/issues/742#issuecomment-9082139 và https://github.com/sparklemotion/nokogiri/issues/829 –

+0

Bạn có thể thử câu trả lời này: http: // stackoverflow. com/questions/24091869/install-nokogiri-on-osx-10-10-yosemite? answerertab = active # tab-top – activars

Trả lời

3

Tôi vừa cài đặt đầy đủ Rails và Ruby và mọi thứ bạn cần. Tôi đã làm theo các bước này.

https://gorails.com/setup/osx/10.10-yosemite

và sử dụng sau để cài đặt nokogiri

xcode-select --install 
gem install nokogiri 
bundle config build.nokogiri --use-system-libraries 
bundle install 
+2

Đẹp. Chỉ cần dòng đầu tiên 'xcode-select --install', sau đó tôi đã có thể 'bundle install' mà không có vấn đề gì. – colllin

0

tôi nhận này để làm việc bằng macports thay vì homebrew. Cấu hình của tôi:

  1. Cài đặt phiên bản Xcode mới nhất (Beta 3 tại thời điểm viết).
  2. xcode-select --switch /Applications/Xcode-Beta3
  3. macports xây dựng/cài đặt từ nguồn, theo hướng dẫn cài đặt here
  4. sudo port install libxml2 libxslt
  5. gem install nokogiri -- --with-iconv-include=/opt/local/include/

Một chút phức tạp, nhưng tất cả mọi thứ đã làm việc tốt sau đó.

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