2

I am sorry but I think I try everything I have seen on the internet to make it works but it always fails :(

I have to work on an old rails project with ruby 2.1.10 and when I bundle update the nokogiri '1.6.3.1' build fail.

It work's well with ruby 2.6.6 and nokogiri-1.10.10

I have install libxml2 and libxsl with homebrew xcode is install and I have read and agreed on the license

I try to install nokogiri link that gem install nokogiri -v '1.6.3.1' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2 --with-xslt-include=$(brew --prefix libxslt)/include/libxslt

and this is the output

Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt'
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
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 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/lokhi/.rbenv/versions/2.1.10/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=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --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
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out

I have try with nothing gem install nokogiri -v '1.6.3.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/lokhi/.rbenv/versions/2.1.10/bin/ruby 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/lokhi/.rbenv/versions/2.1.10/bin/ruby
   --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/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out

and with only gem install nokogiri -v '1.6.3.1' -- --use-system-libraries

Building native extensions with: '--use-system-libraries'
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
   ERROR: Failed to build gem native extension.

   /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
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 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/lokhi/.rbenv/versions/2.1.10/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
   --with-xsltlib
   --without-xsltlib
   --with-libxsltlib
   --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out

More information about my system clang -v

Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I don't know what to try now have you got an idea, please?

Thanks

EDIT add new information

ls /usr/local/share/aclocal/
README            glib-2.0.m4       gsettings.m4      introspection.m4  lib-prefix.m4     ltdl.m4           lt~obsolete.m4    pkg.m4
dirlist           glib-gettext.m4   host-cpu-c-abi.m4 ksba.m4           libtool.m4        ltoptions.m4      nls.m4            po.m4
freetype2.m4      gpg-error.m4      iconv.m4          lib-ld.m4         libxml.m4         ltsugar.m4        nspr.m4           progtest.m4
gettext.m4        gpgrt.m4          intlmacosx.m4     lib-link.m4       ltargz.m4         ltversion.m4      orc.m4            wxwin.m4
ls /usr/local/opt/libxml2/share/aclocal/
libxml.m4
cat /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
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 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/lokhi/.rbenv/versions/2.1.10/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=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --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
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1

and output of mkmf.log

              _Nonnull
conftest.c:15:15: error: implicit declaration of function 'xsltParseStylesheetDoc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
int t(void) { xsltParseStylesheetDoc(); return 0; }
              ^
194 warnings and 1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <libxslt/xslt.h>
 4:
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12:
13:   return 0;
14: }
15: int t(void) { xsltParseStylesheetDoc(); return 0; }
/* end */

After libxml2 downgrade

This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries
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 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/lokhi/.rbenv/versions/2.1.10/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
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out

and exactly same output for mkmf.log

lokhi
  • 177
  • 1
  • 10
  • Assuming you're using MacOs, could you try this: https://stackoverflow.com/questions/26473197/how-to-install-libxml2-dev-libxslt-dev-on-mac-os – Jad Nov 26 '20 at 10:10
  • No, it does not work :( I have the same error message – lokhi Nov 26 '20 at 15:21
  • `libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.` ... your version of libxml2 is too new! :( can you try to install an older version? – Jad Dec 03 '20 at 16:37
  • I have downgrade the libxml2 to 2.7.2 I have always the libxslt is missing but no more the warning about libxml2 2.9.0 – lokhi Dec 04 '20 at 22:18
  • Now you've downgraded that, are you able to follow the nokogiri Macos tutorial in my answer? – Jad Dec 05 '20 at 23:09
  • no always same error message. But they said "Make sure ruby is compiled with the latest clang compiler." I will try to remove ruby and reinstall it do be sure to compile it with te same version of clang I don't know if it was update on BigSur – lokhi Dec 07 '20 at 09:21
  • I have uninstalled ruby and reinstall it and it works now! thanks a lot @jad for your time and help. – lokhi Dec 10 '20 at 10:42
  • I'm just glad you got it working, despite the "help" I gave you :) – Jad Dec 10 '20 at 13:03

2 Answers2

1

#EDIT#

Nokogiri has a tutorial about installing on MacOS:

https://nokogiri.org/tutorials/installing_nokogiri.html#macos

Can you try the steps in that document?

old information:

as per: libxml2 and libxml2-dev on OSX

brew link --force libxml2

or possibly:

ln -s /usr/local/opt/libxml2/share/aclocal/libxml.m4 /usr/local/share/aclocal/libxml.m4
Jad
  • 1,257
  • 12
  • 19
  • can you `ls /usr/local/share/aclocal/` and see if there are other files, and also `ls /usr/local/opt/libxml2/share/aclocal/` and see if there are missing xml files that you might also want to link? – Jad Nov 29 '20 at 18:45
  • I had edit the post to add new information about ls the two directories – lokhi Dec 03 '20 at 07:27
  • updated my answer with a better more helpful document on the nokogiri website, so hopefully it'll have the steps you need to get it working – Jad Dec 03 '20 at 09:14
  • Thanks I have test all the list bu always the same error with libxslt :( – lokhi Dec 03 '20 at 10:17
  • can you have a look at `/Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out` and see if there are any more specific compile errors, rather than just a "No" ... it should be close to the end of the file – Jad Dec 03 '20 at 10:22
  • I am sorry thanks for your help, I have edit the post with the output of gem_make.out – lokhi Dec 03 '20 at 14:38
  • oh, not that file, I meant the `mkmf.log` that was talked about ... sorry – Jad Dec 03 '20 at 16:05
0

I see you already have installed libxml2, also try installing libxslt, libxslt-devel and I think there was also a dependency to openssl-devel at some point.

Nick M
  • 2,424
  • 5
  • 34
  • 57