Summary: Trying to install nokogiri on OS X 10.13.1 causes an error.
gem install nokogiri -v '1.8.1'
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20171116-69677-7ftiet.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.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.5.
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.5.tar.gz into tmp/x86_64-apple-darwin17.2.0/ports/libxml2/2.9.5... OK
Running 'configure' for libxml2 2.9.5... OK
Running 'compile' for libxml2 2.9.5... ERROR, review '/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.8.1/
ext/nokogiri/tmp/x86_64-apple-darwin17.2.0/ports/libxml2/2.9.5/compile.log' to see what happened. Last lines are:
========================================================================
"_gzwrite", referenced from:
_xmlGzfileWrite in libxml2.a(xmlIO.o)
"_inflate", referenced from:
_xmlNanoHTTPRead in libxml2.a(nanohttp.o)
"_inflateEnd", referenced from:
_xmlNanoHTTPFreeCtxt in libxml2.a(nanohttp.o)
"_inflateInit2_", referenced from:
_xmlNanoHTTPScanAnswer in libxml2.a(nanohttp.o)
"_libiconv", referenced from:
_xmlIconvWrapper in libxml2.a(encoding.o)
"_libiconv_close", referenced from:
_xmlFindCharEncodingHandler in libxml2.a(encoding.o)
_xmlCharEncCloseFunc in libxml2.a(encoding.o)
"_libiconv_open", referenced from:
_xmlFindCharEncodingHandler in libxml2.a(encoding.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [xmllint] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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=/usr/local/var/rbenv/versions/2.3.1/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
/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block i
n execute': Failed to complete compile task (RuntimeError)
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:37
3:in `chdir'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:37
3:in `execute'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:11
5:in `compile'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:15
4:in `cook'
from extconf.rb:365:in `block (2 levels) in process_recipe'
from extconf.rb:257:in `block in chdir_for_build'
from extconf.rb:256:in `chdir'
from extconf.rb:256:in `chdir_for_build'
from extconf.rb:364:in `block in process_recipe'
from extconf.rb:262:in `tap'
from extconf.rb:262:in `process_recipe'
from extconf.rb:548:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/nokogiri-1.8.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/nokogiri-1.8.1/
gem_make.out
"clang -o conftest -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"clang -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
"clang -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -Werror -c conftest.c"
error: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Werror,-Wunknown-warning-option]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
have_header: checking for iconv.h... -------------------- yes
"clang -E -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <iconv.h>
/* end */
--------------------
have_library: checking for gzdopen() in -lz... -------------------- yes
"clang -o conftest -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -lz -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <zlib.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) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return !p; }
/* end */
--------------------
have_iconv?: checking for iconv... -------------------- yes
"clang -o conftest -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_main in conftest-f3bca7.o
"_iconv_open", referenced from:
_main in conftest-f3bca7.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdlib.h>
4: #include <iconv.h>
5:
6: int main(void)
7: {
8: iconv_t cd = iconv_open("", "");
9: iconv(cd, NULL, NULL, NULL, NULL);
10: return EXIT_SUCCESS;
11: }
/* end */
"clang -o conftest -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin17 -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/usr/local/var/rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/usr/local/var/rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -L. -L/usr/local/var/rbenv/versions/2.3.1/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -liconv -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdlib.h>
4: #include <iconv.h>
5:
6: int main(void)
7: {
8: iconv_t cd = iconv_open("", "");
9: iconv(cd, NULL, NULL, NULL, NULL);
10: return EXIT_SUCCESS;
11: }
/* end */
--------------------
gem update --system
xcode-select --install
Both commands ran without error, but gem install nokogiri still failed afterwards
gem install nokogiri -v '1.6.8'I'm getting the same issue here, even when installing with system libraries.
@dstansby Thanks!
Could you please try
pkg-config --cflags libxml-2.0
pkg-config --cflags libxslt
?
Is it the system Ruby, Homebrew Ruby or some Ruby in your user space?
$ pkg-config --cflags libxml-2.0
-I/opt/local/include/libxml2
$ pkg-config --cflags libxslt
-I/opt/local/include -I/opt/local/include/libxml2
I've just realised I'm actually getting a slightly different error (should I open a new issue?):
$ cat /Users/dstansby/github/dstansby.github.io/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/mkmf.log
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -L /BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib -L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib -arch x86_64 -arch i386 -lruby.2.3.0 -lpthread -ldl -lobjc "
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"xcrun clang -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include -arch x86_64 -arch i386 -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
"xcrun clang -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include -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 */
"pkg-config --exists libxml-2.0"
| pkg-config --libs libxml-2.0
=> "-L/opt/local/lib -lxml2\n"
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -L /BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib -L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib -arch x86_64 -arch i386 -lruby.2.3.0 -L/opt/local/lib -lxml2 -lpthread -ldl -lobjc "
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: ignoring file /opt/local/lib/libxml2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libxml2.dylib
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
package configuration for libxml-2.0 is not found
"pkg-config --exists libxslt"
| pkg-config --libs libxslt
=> "-L/opt/local/lib -lxslt -lxml2 -lz -llzma -lpthread -liconv -lm -lxml2\n"
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -L /BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib -L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib -arch x86_64 -arch i386 -lruby.2.3.0 -L/opt/local/lib -lxslt -lxml2 -lz -llzma -lpthread -liconv -lm -lxml2 -lpthread -ldl -lobjc "
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: ignoring file /opt/local/lib/libxslt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libxslt.dylib
ld: warning: ignoring file /opt/local/lib/libxml2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libxml2.dylib
ld: warning: ignoring file /opt/local/lib/libz.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libz.dylib
ld: warning: ignoring file /opt/local/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/liblzma.dylib
ld: warning: ignoring file /opt/local/lib/libiconv.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libiconv.dylib
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
package configuration for libxslt is not found
"pkg-config --exists libexslt"
| pkg-config --libs libexslt
=> "-L/opt/local/lib -lexslt -lxslt -lxml2 -lz -llzma -lpthread -liconv -lm -lxml2\n"
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -L /BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib -L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib -arch x86_64 -arch i386 -lruby.2.3.0 -L/opt/local/lib -lexslt -lxslt -lxml2 -lz -llzma -lpthread -liconv -lm -lxml2 -lpthread -ldl -lobjc "
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/lib'
ld: warning: ignoring file /opt/local/lib/libexslt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libexslt.dylib
ld: warning: ignoring file /opt/local/lib/libxslt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libxslt.dylib
ld: warning: ignoring file /opt/local/lib/libxml2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libxml2.dylib
ld: warning: ignoring file /opt/local/lib/libz.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libz.dylib
ld: warning: ignoring file /opt/local/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/liblzma.dylib
ld: warning: ignoring file /opt/local/lib/libiconv.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libiconv.dylib
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
package configuration for libexslt is not found
"xcrun clang -E -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include 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 */
@dstansby Did you installed the libxml yourself? My xml locates at /usr/lib/libxslt.1.dylib, and it is universal (32 bit and 64 bit). Your libxml only supports 64 bit architecture, but Nokogiri seems to prefer 32 bit.
You can check it with
file /opt/local/lib/libexslt.dylib
which should tell you that it is 64 bit (AKA x86_64 or x64) only.
I had a macports version of libxml, which I've uninstalled.
$ file /opt/local/lib/libexslt.dylib
/opt/local/lib/libexslt.dylib: Mach-O 64-bit dynamically linked shared library x86_64
Is this what I should be seeing? Thanks for the help!
@dstansby Then that's the issue. However, AFAIK, Nokogiri should be able to compile in 64 bit (because many users managed to install with Brewed libxml, which is 64 bit only); I'll investigate it tonight and try to reproduce this issue.
Meanwhile, do you have the macOS libxml, that is, /usr/lib/libxml2.dylib? That one should work without this issue.
@dstansby bump?
@franklinyu thank you for chasing this issue!
Im having the same issue, is there any workaround at the moment?
@fandyd What did you tried? Did you tried install with system libraries?
@dstansby @nwshane bump?
@franklinyu apparently using homebrew libxml2 works, Thanks
Sorry, this dropped off my radar, but all seems to be fine now. Thanks for the support @franklinyu!
I had this build issue with Xcode 8 on 10.13.2 - upgrading to Xcode 9.2 removed the build issue
Was getting the same error on a different mac for a while, incase it's useful here's what I did to fix it:
bundle config build.nokogiri --use-system-libraries--with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2bundle install@dstansby @fandyd Were you able to install with libxml coming with Xcode? That is, /usr/include/libxml2? In addition, what does pkg-config --cflags libxml-2.0 give?
I didn't have much success using Xcode libxml, and
$ pkg-config --cflags libxml-2.0
-I/usr/include/libxml2
@dstansby Would you mind sharing error message when building against Xcode libxml?
Not sure what would be helpful here but I've never had macports installed on this machine and have only used homebrew. I hit this on my 10.13.3 box. I can't say I'm terribly familiar with Ruby but I was just trying to use github-pages locally. I've hit a very similar error.
Fetching nokogiri 1.8.2
Installing nokogiri 1.8.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/cardoe/.gem/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r
./siteconf20180204-42997-12f0oen.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.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.7.
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.7.tar.gz into
tmp/x86_64-apple-darwin17/ports/libxml2/2.9.7... OK
Running 'configure' for libxml2 2.9.7... OK
Running 'compile' for libxml2 2.9.7... ERROR, review
'/Users/cardoe/.gem/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri/tmp/x86_64-apple-darwin17/ports/libxml2/2.9.7/compile.log'
to see what happened. Last lines are:
========================================================================
CCLD libxml2.la
CC testdso.lo
CCLD testdso.la
CC xmllint.o
CCLD xmllint
ld: warning: ignoring file /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib, file
was built for x86_64 which is not the architecture being linked (i386):
/usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib
Undefined symbols for architecture i386:
"_lzma_auto_decoder", referenced from:
_xz_head in libxml2.a(xzlib.o)
"_lzma_code", referenced from:
_xz_decomp in libxml2.a(xzlib.o)
"_lzma_end", referenced from:
___libxml2_xzclose in libxml2.a(xzlib.o)
"_lzma_properties_decode", referenced from:
_is_format_lzma in libxml2.a(xzlib.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [xmllint] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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.3/usr/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
/Users/cardoe/.gem/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in
`block in execute': Failed to complete compile task (RuntimeError)
from
/Users/cardoe/.gem/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in
`chdir'
from
/Users/cardoe/.gem/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in
`execute'
from
/Users/cardoe/.gem/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in
`compile'
from
/Users/cardoe/.gem/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in
`cook'
from extconf.rb:365:in `block (2 levels) in process_recipe'
from extconf.rb:257:in `block in chdir_for_build'
from extconf.rb:256:in `chdir'
from extconf.rb:256:in `chdir_for_build'
from extconf.rb:364:in `block in process_recipe'
from extconf.rb:262:in `tap'
from extconf.rb:262:in `process_recipe'
from extconf.rb:551:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/Users/cardoe/.gem/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/Users/cardoe/.gem/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection.
Results logged to
/Users/cardoe/.gem/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/gem_make.out
An error occurred while installing nokogiri (1.8.2), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.2'` succeeds before bundling.
In Gemfile:
github-pages was resolved to 175, which depends on
jekyll-mentions was resolved to 1.2.0, which depends on
html-pipeline was resolved to 2.7.1, which depends on
nokogiri
I don't have libxml2 or libxslt installed from Homebrew. But I do have liblzma from Homebrew.
$ file /usr/lib/libxml2.dylib
/usr/lib/libxml2.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386]
/usr/lib/libxml2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libxml2.dylib (for architecture i386): Mach-O dynamically linked shared library i386
$ file /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib
/usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib: Mach-O 64-bit dynamically linked shared library x86_64
$ file /usr/lib/liblzma.dylib
/usr/lib/liblzma.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386]
/usr/lib/liblzma.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/liblzma.dylib (for architecture i386): Mach-O dynamically linked shared library i386
$ pkg-config --cflags liblzma
-I/usr/local/Cellar/xz/5.2.3/include
@cardoe The issue you met does not seem similar with OP, but instead more related to the “Error Message About Undeclared Identifier LZMA_OK” section. Note the _lzma_ prefix mentioned in error message.
Figured the fact that it failed to build the built in libxml2 due to dependency issues made it similar. OP had an issue with libxslt while I had an issue with liblzma. But I'll try that. Thanks.
@cardoe please check out the installation tutorial for help with the LZMA error you're seeing. http://www.nokogiri.org/tutorials/installing_nokogiri.html
@cardoe Any news? If not, I guess @flavorjones would close this issue to keep the issue tracker tidy.
Yes. Your suggestion @franklinyu solved it. I was originally just trying to install Jekyll per the GitHub docs when I ran into this issue. I wasn't specifically trying to install this package so I simply searched for the error I encountered and it brought me directly to this issue. It looked similar enough to my error to warrant me commenting.
Closing.
I solved this by running
gem install libxml-ruby -v '3.0.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include
@Korayem You should not have needed that. It’s 2019 and you should be able to gem install nokogiri. If that didn’t work, did you try the second recommended way, Install with system libraries?
Locking this issue.
Most helpful comment
Was getting the same error on a different mac for a while, incase it's useful here's what I did to fix it:
bundle config build.nokogiri --use-system-libraries--with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2bundle install