Installation error on macOS 10.15.6 | Nokogiri 1.8.1 and 1.9.1 | Ruby 2.2.10

114 views
Skip to first unread message

Brahmana

unread,
Sep 22, 2020, 8:32:58 AM9/22/20
to nokogiri-talk
Hi,

I am trying to upgrade Nokogiri from 1.6.7 to at least 1.8.1 (Needed by the savon 2.12.1 gem) but the installation is erroring out with a message that implies that libxslt is not found. However I thought libxslt was packaged with Nokogiri itself. I am not using system libraries.

I have tried Nokogiri version 1.8.1 and 1.9.1. I cannot move to 1.10 since Ruby 2.2. is not supported for 1.10 and above.

Any help in resolving this will be greatly appreciated. Details of the system and errors are below. Let me know if any more details are needed.

System details : 

macOS Catalina 10.15.6
Xcode : Version 12.0 (12A7209) - Updated to this version yesterday
xcode-select version 2373 (Command line tools are installed)
Ruby 2.2.10 - Compiled from source before the Xcode upgrade

The output of bundle install is pasted below. The mkmf.log is attached.

Fetching mini_portile2 2.4.0 (was 2.0.0)
Installing mini_portile2 2.4.0 (was 2.0.0)
Fetching nokogiri 1.9.1 (was 1.6.7)
Installing nokogiri 1.9.1 (was 1.6.7) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/srirang/.rubies/ruby-2.2.10/bin/ruby -r ./siteconf20200922-26812-iq55mq.rb extconf.rb
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 packaged libraries.
Using mini_portile version 2.4.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv using --with-opt-* flags... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.8
with the following patches applied:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
- 0002-Fix-nullptr-deref-with-XPath-logic-ops.patch
- 0003-Fix-infinite-loop-in-LZMA-decompression.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.8.tar.gz into tmp/x86_64-apple-darwin19.5.0/ports/libxml2/2.9.8... OK
Running git apply with /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch... OK
Running git apply with /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/patches/libxml2/0002-Fix-nullptr-deref-with-XPath-logic-ops.patch... OK
Running git apply with /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/patches/libxml2/0003-Fix-infinite-loop-in-LZMA-decompression.patch... OK
Running 'configure' for libxml2 2.9.8... OK
Running 'compile' for libxml2 2.9.8... OK
Running 'install' for libxml2 2.9.8... OK
Activating libxml2 2.9.8 (from /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/ports/x86_64-apple-darwin19.5.0/libxml2/2.9.8)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.32.

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Extracting libxslt-1.1.32.tar.gz into tmp/x86_64-apple-darwin19.5.0/ports/libxslt/1.1.32... OK
Running 'configure' for libxslt 1.1.32... OK
Running 'compile' for libxslt 1.1.32... OK
Running 'install' for libxslt 1.1.32... OK
Activating libxslt 1.1.32 (from /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/ports/x86_64-apple-darwin19.5.0/libxslt/1.1.32)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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
--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/srirang/.rubies/ruby-2.2.10/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
--with-xsltlib
--without-xsltlib
--with-libxsltlib
--without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1 for inspection.
Results logged to /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/nokogiri-1.9.1/gem_make.out

An error occurred while installing nokogiri (1.9.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.9.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  savon was resolved to 2.12.1, which depends on
    akami was resolved to 1.3.1, which depends on
      nokogiri


mkmf.log

Walter Lee Davis

unread,
Sep 22, 2020, 8:54:21 AM9/22/20
to nokogiri-talk
Nokogiri used to package libxml and libxslt within the gem, but that was dropped in the 1.7 era, IIRC, in favor of smaller downloads and using the system packages. (That's coming full circle in the next version of Noko! I saw a tantalizing message about that last week or so; where the entire binary is being sent precompiled within the gem, which should give us sub-1-second install times on modern hardware, but I digress.) I believe that in order to compile the binary for Nokogiri in the range of versions you need, you will have to have access to the headers for libxml and libxslt on your server.

Walter
> --
> You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nokogiri-talk/12b206f8-3705-4cbf-ba6b-b19aa9287b6bn%40googlegroups.com.
> <mkmf.log>

Brahmana

unread,
Sep 22, 2020, 4:16:14 PM9/22/20
to nokogiri-talk
Hi Walter,

That is interesting. I did not find that information in the Changelog.

So what does this part of the output means? I thought it was the packaged libxslt being built. Is it not?

Extracting libxslt-1.1.32.tar.gz into tmp/x86_64-apple-darwin19.5.0/ports/libxslt/1.1.32... OK
Running 'configure' for libxslt 1.1.32... OK
Running 'compile' for libxslt 1.1.32... OK
Running 'install' for libxslt 1.1.32... OK
Activating libxslt 1.1.32 (from /Users/srirang/.bundles/pw_ruby2.1.2/ruby/2.2.0/gems/nokogiri-1.9.1/ports/x86_64-apple-darwin19.5.0/libxslt/1.1.32)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  Please locate mkmf.log to investigate how it is failing.
-----

Mike Dalessio

unread,
Sep 22, 2020, 4:24:12 PM9/22/20
to nokogiri-talk
Hi,

Sorry you're having trouble. Walter's response is not entirely correct -- we do still ship libxml2 and libxslt source within Nokogiri.

I'm not sure we're going to be able to help you, unfortunately. But I'll try. The key challenge is that you're using a modern Xcode but an older (out-of-support!) Nokogiri. Xcode 10 and later changed where system library paths exist on disk, and how to find them -- Nokogiri v1.10.1 and later are updated to handle those versions of Xcode. I'm not positive that this is the problem you're seeing, but it seems possible.

If there's any way you can upgrade to a supported version of Ruby and a supported version of Nokogiri, I'd ask that you try to do that.

As a fallback, I'd suggest trying to install libxml2 and libxslt system libraries, and then install Nokogiri with the `--use-system-libraries` option -- the instructions here may be helpful: https://nokogiri.org/tutorials/installing_nokogiri.html#install-with-custom-non-standard-libraries

If you're still stuck, reply back to the thread and we'll dig into the specific config problem you're seeing.

Brahmana

unread,
Sep 23, 2020, 8:06:24 AM9/23/20
to nokogiri-talk
[HEADS UP : I am not sure if my previous reply to this was actually posted since I got an error message. If it was, please pardon the duplicate reply]

Mike,

First of all thank you for making this gem and also supporting it so well.

I acknowledge that we need to upgrade our Ruby version. We are doing that but it will take us some time I believe.

I tried --use-system-libraries options but I still get the same error. Below are the full details. Let me know if any more details are needed.

NOTE : I had come across this issue on github on Sep 26, 2018 . I used the xcrun command given there to get the directories of the libraries and include files.

I tried two sets of paths and both failed. Here are the results. The corresponding mkmf.log flies are also attached.

Run - 1

/Users/srirang/.rubies/ruby-2.2.10/bin/ruby -r ./siteconf20200923-44175-10nljsw.rb extconf.rb --use-system-libraries
--with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/libxml
--with-xslt-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
--with-xslt-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxslt
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 xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

Run - 2

/Users/srirang/.rubies/ruby-2.2.10/bin/ruby -r ./siteconf20200923-44233-10nzwct.rb extconf.rb --use-system-libraries
--with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2
--with-xslt-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
--with-xslt-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
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 xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

Directory contents

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxslt
attributes.h       extra.h            keys.h             numbersInternals.h security.h         variables.h        xsltconfig.h       xsltutils.h
documents.h        functions.h        module.modulemap   pattern.h          templates.h        xslt.h             xsltexports.h
extensions.h       imports.h          namespaces.h       preproc.h          transform.h        xsltInternals.h    xsltlocale.h

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxslt*
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxslt.1.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxslt.tbd

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/libxml
DOCBparser.h       catalog.h          globals.h          parser.h           threads.h          xmlIO.h            xmlreader.h        xmlunicode.h
HTMLparser.h       chvalid.h          hash.h             parserInternals.h  tree.h             xmlautomata.h      xmlregexp.h        xmlversion.h
HTMLtree.h         debugXML.h         list.h             pattern.h          uri.h              xmlerror.h         xmlsave.h          xmlwriter.h
SAX.h              dict.h             module.modulemap   relaxng.h          valid.h            xmlexports.h       xmlschemas.h       xpath.h
SAX2.h             encoding.h         nanoftp.h          schemasInternals.h xinclude.h         xmlmemory.h        xmlschemastypes.h  xpathInternals.h
c14n.h             entities.h         nanohttp.h         schematron.h       xlink.h            xmlmodule.h        xmlstring.h        xpointer.h

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxml*
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxml2.2.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libxml2.tbd
mkmf-run-2.log
mkmf-run-1.log

Brahmana

unread,
Sep 23, 2020, 3:31:56 PM9/23/20
to nokogiri-talk
An update : 

As part of the upgrade process, I tried upgrading to Ruby 2.3.8. Here surprisingly Nokogiri 1.6.7 which was already part of the bundle installed successfully with the same latest Xcode. (NOTE : I am not specifying --use-system-libraries. It is building with the packaged ones)

We are running this on our staging setup now. If it goes well I can safely try Nokogiri 1.10.

However it is surprising that 1.6.7 builds but not 1.8 or 1.9. Any insights?

Reply all
Reply to author
Forward
0 new messages