slather: Bundle install fails due to nokogiri 1.6.8 problem

Yosemite 10.10.5 This was working, and now suddenly it has stopped. The command and it’s subsequent output as well as mkmf.log snippet is included below.

I notice that some of my Jenkins Mac Mini slaves when running the bundle install command install nokogiri 1.6.7.2, this one which is experiencing the failure is trying to install nokogiri 1.6.8. What makes this difference? ============= bundle install ============== bundle install Fetching gem metadata from https://rubygems.org/… Fetching version metadata from https://rubygems.org/… Resolving dependencies… Rubygems 2.0.14 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation. Using i18n 0.7.0 Using json 1.8.3 Using minitest 5.9.0 Using thread_safe 0.3.5 Using claide 1.0.0 Using clamp 0.6.5 Using colored 1.2 Using mini_portile2 2.1.0 Using pkg-config 1.1.7 Using bundler 1.11.2 Using tzinfo 1.2.2 Installing nokogiri 1.6.8 with native extensions

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries

Using pkg-config version 1.1.7 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. checking for libxml-2.0… no checking for libxslt… no checking for libexslt… no ERROR: cannot discover where libxml2 is located on your system. please make sure pkg-config is installed. *** 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-pkg-config –without-pkg-config –with-override-variables –without-override-variables –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-pkg-config –without-pkg-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 –with-pkg-config –without-pkg-config

Gem files will remain installed in /var/folders/8r/84r5yjgs6g79sncp7rjqflnr0000gq/T/bundler20160609-42888-n8l47cnokogiri-1.6.8/gems/nokogiri-1.6.8 for inspection. Results logged to /var/folders/8r/84r5yjgs6g79sncp7rjqflnr0000gq/T/bundler20160609-42888-n8l47cnokogiri-1.6.8/gems/nokogiri-1.6.8/ext/nokogiri/gem_make.out Using activesupport 4.2.6 An error occurred while installing nokogiri (1.6.8), and Bundler cannot continue. Make sure that gem install nokogiri -v '1.6.8' succeeds before bundling.

=============== SNIP mkmf.log ============== “xcrun clang -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS -Wno-error=unused-command-line-argument-hard-error-in-future -arch x86_64 -arch i386 -c conftest.c” warning: unknown warning option ‘-Werror=unused-command-line-argument-hard-error-in-future’; did you mean ‘-Werror=unused-command-line-argument’? [-Wunknown-warning-option] 1 warning generated. warning: unknown warning option ‘-Werror=unused-command-line-argument-hard-error-in-future’; did you mean ‘-Werror=unused-command-line-argument’? [-Wunknown-warning-option] 1 warning generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: int main() {return 0;} / end */

package configuration for libxslt is not found have_package: checking for libxslt… -------------------- no

DL is deprecated, please use Fiddle

package configuration for libexslt is not found have_package: checking for libexslt… -------------------- no


“xcrun clang -E -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c -o conftest.i” conftest.c:3:10: fatal error: ‘libxml/xmlversion.h’ file not found

include <libxml/xmlversion.h>

     ^

1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <libxml/xmlversion.h> / end */

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 26 (1 by maintainers)

Most upvoted comments

I had the same error, only solution that worked for me on OSX:

xcode-select --install
gem install nokogiri

from here: http://stackoverflow.com/a/34653921

This fixes it for me:

gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2

I’ve just updated to macOS Sierra and had this issue, installing the command line tools as mentioned above by @ts-silvio worked for me

xcode-select --install

works for me.

This may happen after I reinstalled Xcode.

bundle install will pick the newest available version satisfying a requirement, unless you specify concrete versions or upper bounds in the Gemfile.

You can check out http://buegling.com/blog/2015/4/26/building-nokogiri-on-os-x for some nokogiri installation troubleshooting advice.

xcode-select --install works for me. I was unable to build the gem after updating to macOS Sierra

Ok I found it out: I had set BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" in ~/.bundle/config which caused problems. I removed the setting via bundle config --delete build.nokogiri. Now my Gemfile containing slather installs without any further workarounds! 🎉

Follow @cmavromoustakos 's solution. I use gem install slather -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2

@ts-silvio’s solution xcode-select --install ; bundle install didn’t work for me, telling me to install pkg-config.

So I brew install pkg-config, but got Error: The 'brew link' step did not complete successfully. So I brew link --overwrite pkg-config And then bundle install works fine

For Sierra, the following code solved my problem (ERROR: Failed to build gem native extension.)

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

Reference, http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x

As @ptibbetts said, I’ve just updated to Sierra, trying to start a Rails 5 project, @ts-silvio 's answer got me past the Nokogiri error.

with newer versions of brew this is something like gem install nokogiri -- --with-xml2-include=/usr/local/opt/libxml2/

do a reinstall of libxml2 with brew and it will tell you where it is located, then use that path. without the --use-system-libraries=true!

Doing bundle update fixes this problem for me. Sometimes you need updating your gems to the latest available versions.

For one of my old Rails 4 application, I wanted to install nokogiri -v 1.6.8.1 and earlier locked version was 1.6.0. When I started installing nokigiri gem (or updating), I was bitten by this same issue.

On my latest macOS Mojave 10.14.4, following option of xcode-select did not work for me.

xcode-select --install

It’s giving error as xcode-select: error: command line tools are already installed, use "Software Update" to install updates and when I check then all softwares are up-to date.

As suggested by @nitrnitr , this solution worked for me finally

bundle config --delete build.nokogiri
gem install nokogiri -v 1.6.8.1 -- --with-xml2-include=/usr/local/opt/libxml2/

tried what @fabb mentioned about deleting BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" in .bundle/config and it fixed the problem for me.

maybe you need to update your ruby

@brendangillies I think what I had to do was to force the install of Nokogiri 1.6.7.2 first. Then I was able to install the slather gem.

-----Original Message----- From: brendangillies notifications@github.com To: SlatherOrg/slather slather@noreply.github.com Cc: mikelupo mikelupo@aol.com; Author author@noreply.github.com Sent: Thu, Jun 30, 2016 11:37 am Subject: Re: [SlatherOrg/slather] Bundle install fails due to nokogiri 1.6.8 problem (#227)

How did you solve this?? Struggling with the same issue but am not able to find the answer here… — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.