安装nokogiri时出错:无法构建gem本机扩展& libiconv丢失(OSX) [英] Error installing nokogiri: Failed to build gem native extension & libiconv is missing (OSX)
问题描述
我尝试克隆此存储库并运行bundle install
.捆绑过程失败,并引发以下错误:
I try to clone this repo and run bundle install
. The bundle process failed and throw this error:
...
Installing nokogiri 1.6.2.1 with native extensions
Building nokogiri using packaged libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20151130-43880-pntnc6.rb 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
--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/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--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
Gem files will remain installed in /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.2.1/gem_make.out
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
然后我尝试运行此命令:
Then I try to run this:
gem install nokogiri -v '1.6.2.1'
现在我收到此错误:
Building native extensions. This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20151130-43942-1axq4sj.rb 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
--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/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--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
Gem files will remain installed in /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.2.1/gem_make.out
我试图遵循此答案,但上面我仍然遇到相同的错误.
I tried to follow this answer but I still get the same error above.
我也尝试再次卸载并安装我的brew(基于此答案 ),并且仍然相同.
I also try to uninstall and install my brew again (based on this answer) and it's still same.
此外,我尝试此解决方案,但仍然会收到错误消息.
Also, I try this solution but still get the error.
我现在应该怎么做才能确保成功安装此nokogiri gem?
What should I do now to make sure this nokogiri gem installed successfully?
注意:我正在使用OSX 10.11.1 El Capitan.
Note: I'm using OSX 10.11.1 El Capitan.
推荐答案
运行以下命令:
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
来源: http://www.nokogiri.org/tutorials/installing_nokogiri.html# mac_os_x
有时mac更新可能会破坏xcode CLI,因此重新安装可以解决此问题: https://github.com/sparklemotion/nokogiri/issues/1445
sometimes mac updates can break xcode CLI so reinstalling can fix the issue: https://github.com/sparklemotion/nokogiri/issues/1445
这篇关于安装nokogiri时出错:无法构建gem本机扩展& libiconv丢失(OSX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!