Nokogiri: Installation of nokogiri fail with bundle on macOS Sierra 10.12

Created on 13 Oct 2016  ·  4Comments  ·  Source: sparklemotion/nokogiri

Trying to install all the gems of a rails project, I getting a error for install nokogiri, but as you can see in the below logs, I'd already installed the following versions (1.6.8.1, 1.6.6.2), but on the way after bundle Im getting the error.


How do I installed?

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

Trying to run bundle install

Installing nokogiri 1.6.6.2 with native extensions

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

    current directory: /private/var/folders/03/tq1mq3115ll5z1_psdwc3j940000gn/T/bundler20161012-26546-17d13banokogiri-1.6.6.2/gems/nokogiri-1.6.6.2/ext/nokogiri
/Users/fulvio/.rbenv/versions/2.2.5/bin/ruby -r ./siteconf20161012-26546-1ttkbzt.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=/Users/fulvio/.rbenv/versions/2.2.5/bin/$(RUBY_BASE_NAME)
    --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

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/folders/03/tq1mq3115ll5z1_psdwc3j940000gn/T/bundler20161012-26546-17d13banokogiri-1.6.6.2/extensions/x86_64-darwin-15/2.2.0-static/nokogiri-1.6.6.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/folders/03/tq1mq3115ll5z1_psdwc3j940000gn/T/bundler20161012-26546-17d13banokogiri-1.6.6.2/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /var/folders/03/tq1mq3115ll5z1_psdwc3j940000gn/T/bundler20161012-26546-17d13banokogiri-1.6.6.2/extensions/x86_64-darwin-15/2.2.0-static/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.

→ gem list nokogiri

*** LOCAL GEMS ***

nokogiri (1.6.8.1, 1.6.6.2)

→ brew install libxml2
==> Downloading https://homebrew.bintray.com/bottles/libxml2-2.9.4.sierra.bottle.tar.gz
Already downloaded: /Users/fulvio/Library/Caches/Homebrew/libxml2-2.9.4.sierra.bottle.tar.gz
==> Pouring libxml2-2.9.4.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/libxml2/lib
    CPPFLAGS: -I/usr/local/opt/libxml2/include
    PKG_CONFIG_PATH: /usr/local/opt/libxml2/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/libxml2/2.9.4: 276 files, 9.8M
→ tail -100 /Users/fulvio/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/nokogiri-1.6.8.1/mkmf.log
/* end */

--------------------

have_func: checking for xmlSchemaSetValidStructuredErrors()... -------------------- yes

"clang -o conftest -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0/x86_64-darwin15 -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0/ruby/backward -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 -I/Users/fulvio/.rbenv/versions/2.2.5/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe  conftest.c  -L. -L/Users/fulvio/.rbenv/versions/2.2.5/lib -L. -L/Users/fulvio/.rbenv/versions/2.2.5/lib  -fstack-protector    -lexslt -lxslt -lxml2  -lruby-static -framework CoreFoundation -lexslt -lxslt -lxml2  -lpthread -ldl -lobjc  "
conftest.c:13:57: error: use of undeclared identifier 'xmlSchemaSetValidStructuredErrors'
int t(void) { void ((*volatile p)()); p = (void ((*)()))xmlSchemaSetValidStructuredErrors; return 0; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))xmlSchemaSetValidStructuredErrors; return 0; }
/* end */

"clang -o conftest -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0/x86_64-darwin15 -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0/ruby/backward -I/Users/fulvio/.rbenv/versions/2.2.5/include/ruby-2.2.0 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 -I/Users/fulvio/.rbenv/versions/2.2.5/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe  conftest.c  -L. -L/Users/fulvio/.rbenv/versions/2.2.5/lib -L. -L/Users/fulvio/.rbenv/versions/2.2.5/lib  -fstack-protector    -lexslt -lxslt -lxml2  -lruby-static -framework CoreFoundation -lexslt -lxslt -lxml2  -lpthread -ldl -lobjc  "
conftest.c:13:15: warning: implicit declaration of function 'xmlSchemaSetValidStructuredErrors' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { xmlSchemaSetValidStructuredErrors(); return 0; }
              ^
1 warning generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
13: int t(void) { xmlSchemaSetValidStructuredErrors(); return 0; }
/* end */

--------------------
metuser-help platforosx

Most helpful comment

solution
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2

All 4 comments

solution
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2

For OSX 10.13
The above solution almost works, but must be adjusted for OSX 10.13 like this:
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2

Note the change from MacOSX10.12.sdk to MacOSX10.13.sdk

For OSX 10.14
Use:
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 --with-xslt-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxslt --with-exslt-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libexslt

If someone would like to make a pull request update documentation at https://github.com/sparklemotion/nokogiri.org-tutorials it would be greatly appreciated and received. Unfortunately I'm not a Mac user and cannot verify anything in this thread.

Was this page helpful?
0 / 5 - 0 ratings