我的一位开发人员更新了 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/ruby-2.1.2@my-project/gems/nokogiri-1.6.7 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-2.1.2@my-project/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.
如“Failing to install Nokogiri gem”中的建议,我尝试运行失败:
bundle config build.nokogiri --use-system-libraries
bundle install
按照“Failing to install Nokogiri gem”中的建议,我也尝试过:
gem install nokogiri -- --use-system-libraries
和:
gem install nokogiri -v 1.6.5 -- --use-system-libraries
我的操作系统版本是 El Capitan 10.11.2,我已经检查过 Xcode 许可协议(protocol)已被接受。
有什么想法可以让 Nokogiri 安装成功吗?
最佳答案
您应该先安装xcode-select
包,然后再次尝试安装nokogiri。试试这些命令,
xcode-select --install
然后尝试
gem install nokogiri
使用您想要的任何 Nokogiri 版本。
Nokogiri 依赖于多个库,如 libxslt、libxml 和 zlib。在任何 Linux 发行版中安装 Nokogiri 之前,应安装这些的开发版本(包括源代码)。对于 OS X,我猜上面的命令应该可以工作。
实际的解决方案在下面的评论中。
关于ruby-on-rails - 在 El Capitan 上安装 Nokogiri (1.6.7) 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34651519/