2015-08-28 1 views
0

Я начинаю приложение Middleman с нуля. Всякий раз, когда я пытаюсь запустить сервер, то есть middleman server Я получаю сообщение об ошибке (ниже), которое говорит мне «Ошибка при установке nokogiri (1.6.6.2), и Bundler не может продолжаться».Ошибка для установки gem nokogiri И установка пакета для приложения Middleman

Однако, когда я пытаюсь установить nokogiri (1.6.6.2), я получаю еще одну ошибку (ниже), которая говорит мне: «ОШИБКА: Ошибка при установке nokogiri: ОШИБКА: Не удалось создать собственное расширение gem.»

Затем я пытаюсь выполнить bundle install свой gemfile, но получаю еще одну ошибку. Может ли кто-нибудь сказать мне, что я могу игнорировать?

Всякий раз, когда я пытаюсь запустить мою middleman server команду, я получаю это:

/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'nokogiri' (>= 1.3.3) among 67 total gem(s) (Gem::LoadError) 
Checked in 'GEM_PATH=/Users/Wilhelm/.gem/ruby/2.0.0:/Library/Ruby/Gems/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0', execute `gem env` for more information 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1311:in `block in activate_dependencies' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `each' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `activate_dependencies' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1282:in `activate' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1314:in `block in activate_dependencies' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `each' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `activate_dependencies' 
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1282:in `activate' 
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem' 
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `synchronize' 
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `gem' 
    from /usr/bin/middleman:22:in `<main>' 

Вот содержание моего Gemfile:

# If you do not have OpenSSL installed, update 
# the following line to use "http://" instead 
source 'https://rubygems.org' 

gem "middleman", "~>3.4.0" 

# Live-reloading plugin 
gem "middleman-livereload", "~> 3.1.0" 

# For faster file watcher updates on Windows: 
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] 

# Windows does not come with time zone data 
gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby] 

и вот результаты от моего bundle install:

Fetching gem metadata from https://rubygems.org/............. 
Fetching version metadata from https://rubygems.org/... 
Fetching dependency metadata from https://rubygems.org/.. 
Resolving dependencies... 
Using i18n 0.7.0 
Using json 1.8.3 
Using minitest 5.8.0 
Using thread_safe 0.3.5 
Using tzinfo 1.2.2 
Using activesupport 4.2.4 
Using bundler 1.8.2 
Using mime-types 2.6.1 
Using mini_portile 0.6.2 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150828-20513-wkpoce.rb extconf.rb --use-system-libraries 
checking if the C compiler accepts ... yes 
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no 
Building nokogiri using system libraries. 
libxml2 version 2.6.21 or later is required! 
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 
    --help 
    --clean 
    --use-system-libraries 
    --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-xml2-dir 
    --without-xml2-dir 
    --with-xml2-include 
    --without-xml2-include=${xml2-dir}/include 
    --with-xml2-lib 
    --without-xml2-lib=${xml2-dir}/lib 
    --with-libxml-2.0-config 
    --without-libxml-2.0-config 
    --with-pkg-config 
    --without-pkg-config 
    --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-exslt-dir 
    --without-exslt-dir 
    --with-exslt-include 
    --without-exslt-include=${exslt-dir}/include 
    --with-exslt-lib 
    --without-exslt-lib=${exslt-dir}/lib 
    --with-libexslt-config 
    --without-libexslt-config 

extconf failed, exit code 1 

Gem files will remain installed in /var/folders/zn/zh_8qnr573x4wgbjz6gqz72w0000gn/T/bundler20150828-20513-11hlulx/nokogiri-1.6.6.2/gems/nokogiri-1.6.6.2 for inspection. 
Results logged to /var/folders/zn/zh_8qnr573x4wgbjz6gqz72w0000gn/T/bundler20150828-20513-11hlulx/nokogiri-1.6.6.2/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.6.2/gem_make.out 
An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot 
continue. 
Make sure that `gem install nokogiri -v '1.6.6.2'` succeeds before bundling. 

и вот результаты от моего sudo gem install nokogiri -v '1.6.6.2' :

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

     /Users/Wilhelm/.rbenv/versions/1.9.3-dev/bin/ruby extconf.rb 
checking if the C compiler accepts ... yes 
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no 
Building nokogiri using packaged libraries. 
----- 
The file "/usr/include/iconv.h" is missing in your build environment, 
which means you haven't installed Xcode Command Line Tools properly. 

To install Command Line Tools, try running `xcode-select --install` on 
terminal and follow the instructions. If it fails, open Xcode.app, 
select from the menu "Xcode" - "Open Developer Tool" - "More Developer 
Tools" to open the developer site, download the installer for your OS 
version and run it. 
----- 
*** 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/Wilhelm/.rbenv/versions/1.9.3-dev/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 


Gem files will remain installed in /Users/Wilhelm/.rbenv/versions/1.9.3-dev/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.6.2 for inspection. 
Results logged to /Users/Wilhelm/.rbenv/versions/1.9.3-dev/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.6.2/ext/nokogiri/gem_make.out 

ответ

1

Эта команда:

sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries

найдено в this github issue, решить мою проблему. Честно говоря, я не совсем уверен, почему так, если бы кто-нибудь мог добавить комментарий, выяснение того, что именно происходит, было бы очень оценено.

1

Я столкнулся с этим на нескольких системных конфигурациях. Он всегда оказывается зависимым от библиотеки. Если бы это было мне, по одному за раз, я бы установить их и попытаться установить расслоение:

libxslt-dev 
libxml2-dev 
ruby-dev 

В зависимости от вашей системы (я думаю, что на CentOS они -devel не -dev).