Ошибка при установке Nokogiri (1.6.7) на El Capitan
Один из моих разработчиков обновил Nokogiri, а когда вытащил обновленный Gemfile, мой bundle install
терпит неудачу.
➜ my-project git:(master) bundle install
Fetching source index from https://rubygems.org/
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.3
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby 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=/Users/me/.rvm/rubies/ruby-2.1.2/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 /Users/me/.rvm/gems/[email protected]/gems/nokogiri-1.6.7 for inspection.
Results logged to /Users/me/.rvm/gems/[email protected]/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.7/gem_make.out
An error occurred while installing nokogiri (1.6.7), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7'` succeeds before bundling.
Как указано в "Не удалось установить драгоценный камень Нокогири" Я безуспешно пытался запустить:
bundle config build.nokogiri --use-system-libraries
bundle install
Как указано в "Не удалось установить драгоценный камень Нокогири" Я также пробовал:
gem install nokogiri -- --use-system-libraries
и
gem install nokogiri -v 1.6.5 -- --use-system-libraries
Моя версия ОС - El Capitan 10.11.2, и я проверил, что лицензионное соглашение Xcode принято.
Любые идеи о том, как добиться успеха в установке Nokogiri?
Ответы
Ответ 1
Сначала вы должны установить пакеты xcode-select
, а затем попробовать снова установить nokogiri. Попробуйте эти команды,
xcode-select --install
затем попробуйте
gem install nokogiri
с любой нудной версией Nokogiri.
Nokogiri зависит от нескольких библиотек, таких как libxslt, libxml и zlib. Перед установкой Nokogiri в любом дистрибутиве Linux необходимо установить версии Dev (включая источник). Для OS X указанная выше команда должна работать, я думаю.
Реальное решение приведено в комментариях ниже.
Ответ 2
Попробуйте следующее:
gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
И затем запустите
bundle update
Надеюсь, это может вам помочь:)
Ответ 3
Я использую homebrew для поддержки библиотек, таких как libml на вашем mac, следующая команда на вашем mac может помочь:
gem install nokogiri -v '1.6.8' -- --use-system-libraries --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib/
просто убедитесь, что путь для libxml такой же, как мой, если brew не изменится со следующей версией. Вы можете проверить это, выполнив следующую команду:
brew info libxml2
Ответ 4
Добавьте gem "nokogiri", ">= 1.6.7.rc3"
в свой Gemfile
а затем запустите
bundle install
Ответ 5
попробуйте:
apt-get install ruby-nokogiri
bundle install
Ответ 6
Обновление Xcode и средств командной строки исправило все ошибки для меня. После этого я смогу установить Nokogiri с помощью gem install nokogiri, и после этого жемчужина установила рельсы, работающие нормально.
Ответ 7
Следующие шаги работали для меня
ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Run the following to install RVM and the latest stable version of Ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
Install the Ruby interpreter:
rvm install 2.1.0 --autolibs=enable
After that finished installing, run:
source /Users/{your_user_name}/.rvm/scripts/rvm
Run:
ruby -v
ruby 2.1.0p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
==> sudo gem install bundler
Fetching: bundler-1.14.6.gem (100%)
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Installing ri documentation for bundler-1.14.6
Done installing documentation for bundler after 4 seconds
1 gem installed