Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

bundle install with Nokogiri gem fails #278

Closed
tknerr opened this issue Dec 21, 2014 · 13 comments
Closed

bundle install with Nokogiri gem fails #278

tknerr opened this issue Dec 21, 2014 · 13 comments

Comments

@tknerr
Copy link
Contributor

tknerr commented Dec 21, 2014

Ohai!

Trying to use ChefDK 0.3.5 on Ubuntu 14.04 with a sample cookbook. It fails during bundle install when trying to compile the Nokogiri native gem.

This is what I did:

tkn@dev-box:~/tmp/sample-toplevel-cookbook$ eval "$(chef shell-init bash)"

tkn@dev-box:~/tmp$ git clone https://github.com/tknerr/sample-toplevel-cookbook.git
Cloning into 'sample-toplevel-cookbook'...
remote: Counting objects: 494, done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 494 (delta 10), reused 0 (delta 0)
Receiving objects: 100% (494/494), 62.06 KiB | 0 bytes/s, done.
Resolving deltas: 100% (251/251), done.
Checking connectivity... done.

tkn@dev-box:~/tmp$ cd sample-toplevel-cookbook/

tkn@dev-box:~/tmp/sample-toplevel-cookbook$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using addressable 2.3.6
Using multipart-post 2.0.0
Using faraday 0.9.0
Using berkshelf-api-client 1.2.0
Using buff-extensions 1.0.0
Using hashie 2.1.2
Using varia_model 0.4.0
Using buff-config 1.0.1
Using buff-ruby_engine 0.1.0
Using buff-shell_out 0.2.0
Using hitimes 1.2.2
Using timers 4.0.1
Using celluloid 0.16.0
Using nio4r 1.0.1
Using celluloid-io 0.16.1
Using cleanroom 1.0.0
Using minitar 0.5.4
Using sawyer 0.6.0
Using octokit 3.7.0
Using retryable 1.3.6
Using buff-ignore 1.1.1
Using erubis 2.7.0
Using json 1.8.1
Using mixlib-log 1.6.0
Using mixlib-authentication 1.3.0
Using net-http-persistent 2.9.4
Using semverse 1.2.1
Using ridley 4.1.1
Using dep-selector-libgecode 1.0.2
Using ffi 1.9.6
Using dep_selector 1.0.3
Using solve 1.2.1
Using thor 0.19.1
Using berkshelf 3.2.2
Using libyajl2 1.2.0
Using ffi-yajl 1.3.1
Using rack 1.6.0
Using chef-zero 2.2.1
Using diff-lcs 1.2.5
Using highline 1.6.21
Using mime-types 1.25.1
Using mixlib-cli 1.5.0
Using mixlib-config 2.1.0
Using mixlib-shellout 1.6.1
Using net-ssh 2.9.1
Using net-ssh-gateway 1.2.0
Using net-ssh-multi 1.2.0
Using ipaddress 0.8.0
Using systemu 2.6.4
Using wmi-lite 1.0.0
Using ohai 7.4.0
Using plist 3.1.0
Using coderay 1.1.0
Using method_source 0.8.2
Using slop 3.6.0
Using pry 0.10.1
Using rest-client 1.6.7
Using chef 11.16.4
Using logify 0.2.0
Using chef-api 0.5.0
Using fauxhai 2.2.0
Using rspec-support 3.1.2
Using rspec-core 3.1.7
Using rspec-expectations 3.1.2
Using rspec-mocks 3.1.3
Using rspec 3.1.0
Using chefspec 4.1.1
Using multi_json 1.10.1
Using gherkin 2.12.2
Using mini_portile 0.6.1

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

    /opt/chefdk/embedded/bin/ruby -r ./siteconf20141221-19480-ghfmmg.rb extconf.rb 
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for iconv using --with-opt-* flags... yes
************************************************************************
IMPORTANT NOTICE:

Buidling Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
    - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
    - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.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.2.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK
Running 'configure' for libxml2 2.9.2... OK
Running 'compile' for libxml2 2.9.2... ERROR, review '/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/compile.log' to see what happened.
*** 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=/opt/chefdk/embedded/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
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.1/lib/mini_portile.rb:279:in `block in execute': Failed to complete compile task (RuntimeError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.1/lib/mini_portile.rb:271:in `chdir'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.1/lib/mini_portile.rb:271:in `execute'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.1/lib/mini_portile.rb:70:in `compile'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.1/lib/mini_portile.rb:110:in `cook'
    from extconf.rb:268:in `block in process_recipe'
    from extconf.rb:167:in `tap'
    from extconf.rb:167:in `process_recipe'
    from extconf.rb:455:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5 for inspection.
Results logged to /home/tkn/.chefdk/gem/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.5/gem_make.out
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling.

Looking at the compile.log, I see this:

tkn@dev-box:~/tmp/sample-toplevel-cookbook$ cat /home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/compile.log
make  all-recursive
make[1]: Entering directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
Making all in include
make[2]: Entering directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
Making all in libxml
make[3]: Entering directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include/libxml'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include/libxml'
make[3]: Entering directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[2]: Leaving directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
Making all in .
make[2]: Entering directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
  CC       SAX.lo
  CC       entities.lo
  CC       encoding.lo
  CC       error.lo
  CC       parserInternals.lo
  CC       parser.lo
In file included from /opt/chefdk/embedded/include/lzma.h:281:0,
                 from parser.c:84:
/opt/chefdk/embedded/include/lzma/base.h:218:30: warning: comma at end of enumerator list [-Wpedantic]
  LZMA_PROG_ERROR         = 11,
                              ^
  CC       tree.lo
  CC       hash.lo
  CC       list.lo
  CC       xmlIO.lo
In file included from /opt/chefdk/embedded/include/lzma.h:281:0,
                 from xmlIO.c:39:
/opt/chefdk/embedded/include/lzma/base.h:218:30: warning: comma at end of enumerator list [-Wpedantic]
  LZMA_PROG_ERROR         = 11,
                              ^
  CC       xmlmemory.lo
  CC       uri.lo
  CC       valid.lo
  CC       xlink.lo
  CC       HTMLparser.lo
  CC       HTMLtree.lo
  CC       debugXML.lo
  CC       xpath.lo
xpath.c: In function 'xmlXPathRegisterFuncNS':
xpath.c:4875:5: warning: ISO C forbids passing argument 4 of 'xmlHashAddEntry2' between function pointer and 'void *' [-Wpedantic]
     return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f)));
     ^
In file included from ./include/libxml/parser.h:18:0,
                 from ./include/libxml/globals.h:18,
                 from ./include/libxml/threads.h:35,
                 from ./include/libxml/xmlmemory.h:218,
                 from xpath.c:38:
./include/libxml/hash.h:128:4: note: expected 'void *' but argument is of type 'xmlXPathFunction'
    xmlHashAddEntry2(xmlHashTablePtr table,
    ^
xpath.c: In function 'xmlXPathFunctionLookupNS':
xpath.c:4956:24: warning: ISO C forbids assignment between function pointer and 'void *' [-Wpedantic]
     XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
                        ^
xpath.c: In function 'xmlXPathCompOpEval':
xpath.c:13552:41: warning: ISO C forbids assignment between function pointer and 'void *' [-Wpedantic]
                     XML_CAST_FPTR(func) = op->cache;
                                         ^
xpath.c:13579:31: warning: ISO C forbids assignment between function pointer and 'void *' [-Wpedantic]
                     op->cache = XML_CAST_FPTR(func);
                               ^
In file included from xpath.c:476:0:
xpath.c: At top level:
trionan.c:218:1: warning: 'trio_is_negative' defined but not used [-Wunused-function]
 trio_is_negative
 ^
  CC       xpointer.lo
  CC       xinclude.lo
  CC       nanohttp.lo
  CC       nanoftp.lo
  CC       catalog.lo
  CC       globals.lo
  CC       threads.lo
threads.c:53:12: warning: redundant redeclaration of 'pthread_once' [-Wredundant-decls]
 extern int pthread_once (pthread_once_t *__once_control,
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:505:12: note: previous declaration of 'pthread_once' was here
 extern int pthread_once (pthread_once_t *__once_control,
            ^
threads.c:56:14: warning: redundant redeclaration of 'pthread_getspecific' [-Wredundant-decls]
 extern void *pthread_getspecific (pthread_key_t __key)
              ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1130:14: note: previous declaration of 'pthread_getspecific' was here
 extern void *pthread_getspecific (pthread_key_t __key) __THROW;
              ^
threads.c:58:12: warning: redundant redeclaration of 'pthread_setspecific' [-Wredundant-decls]
 extern int pthread_setspecific (pthread_key_t __key,
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1133:12: note: previous declaration of 'pthread_setspecific' was here
 extern int pthread_setspecific (pthread_key_t __key,
            ^
threads.c:61:12: warning: redundant redeclaration of 'pthread_key_create' [-Wredundant-decls]
 extern int pthread_key_create (pthread_key_t *__key,
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1122:12: note: previous declaration of 'pthread_key_create' was here
 extern int pthread_key_create (pthread_key_t *__key,
            ^
threads.c:64:12: warning: redundant redeclaration of 'pthread_key_delete' [-Wredundant-decls]
 extern int pthread_key_delete (pthread_key_t __key)
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1127:12: note: previous declaration of 'pthread_key_delete' was here
 extern int pthread_key_delete (pthread_key_t __key) __THROW;
            ^
threads.c:67:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:66:12: warning: redundant redeclaration of 'pthread_mutex_init' [-Wredundant-decls]
 extern int pthread_mutex_init ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:760:12: note: previous declaration of 'pthread_mutex_init' was here
 extern int pthread_mutex_init (pthread_mutex_t *__mutex,
            ^
threads.c:69:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:68:12: warning: redundant redeclaration of 'pthread_mutex_destroy' [-Wredundant-decls]
 extern int pthread_mutex_destroy ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:765:12: note: previous declaration of 'pthread_mutex_destroy' was here
 extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
            ^
threads.c:71:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:70:12: warning: redundant redeclaration of 'pthread_mutex_lock' [-Wredundant-decls]
 extern int pthread_mutex_lock ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:773:12: note: previous declaration of 'pthread_mutex_lock' was here
 extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
            ^
threads.c:73:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:72:12: warning: redundant redeclaration of 'pthread_mutex_unlock' [-Wredundant-decls]
 extern int pthread_mutex_unlock ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:784:12: note: previous declaration of 'pthread_mutex_unlock' was here
 extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
            ^
threads.c:75:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:74:12: warning: redundant redeclaration of 'pthread_cond_init' [-Wredundant-decls]
 extern int pthread_cond_init ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:979:12: note: previous declaration of 'pthread_cond_init' was here
 extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
            ^
threads.c:77:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:76:12: warning: redundant redeclaration of 'pthread_cond_destroy' [-Wredundant-decls]
 extern int pthread_cond_destroy ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:984:12: note: previous declaration of 'pthread_cond_destroy' was here
 extern int pthread_cond_destroy (pthread_cond_t *__cond)
            ^
threads.c:79:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:78:12: warning: redundant redeclaration of 'pthread_cond_wait' [-Wredundant-decls]
 extern int pthread_cond_wait ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1000:12: note: previous declaration of 'pthread_cond_wait' was here
 extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
            ^
threads.c:81:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:80:12: warning: redundant redeclaration of 'pthread_equal' [-Wredundant-decls]
 extern int pthread_equal ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:289:12: note: previous declaration of 'pthread_equal' was here
 extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
            ^
threads.c:83:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:82:18: warning: redundant redeclaration of 'pthread_self' [-Wredundant-decls]
 extern pthread_t pthread_self ()
                  ^
In file included from threads.c:28:0:
/usr/include/pthread.h:286:18: note: previous declaration of 'pthread_self' was here
 extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
                  ^
threads.c:85:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:84:12: warning: redundant redeclaration of 'pthread_key_create' [-Wredundant-decls]
 extern int pthread_key_create ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1122:12: note: previous declaration of 'pthread_key_create' was here
 extern int pthread_key_create (pthread_key_t *__key,
            ^
threads.c:87:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:86:12: warning: redundant redeclaration of 'pthread_key_delete' [-Wredundant-decls]
 extern int pthread_key_delete ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:1127:12: note: previous declaration of 'pthread_key_delete' was here
 extern int pthread_key_delete (pthread_key_t __key) __THROW;
            ^
threads.c:89:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
     __attribute((weak));
     ^
threads.c:88:12: warning: redundant redeclaration of 'pthread_cond_signal' [-Wredundant-decls]
 extern int pthread_cond_signal ()
            ^
In file included from threads.c:28:0:
/usr/include/pthread.h:988:12: note: previous declaration of 'pthread_cond_signal' was here
 extern int pthread_cond_signal (pthread_cond_t *__cond)
            ^
  CC       c14n.lo
  CC       xmlstring.lo
  CC       buf.lo
  CC       xmlregexp.lo
  CC       xmlschemas.lo
  CC       xmlschemastypes.lo
  CC       xmlunicode.lo
  CC       xmlreader.lo
  CC       relaxng.lo
  CC       dict.lo
  CC       SAX2.lo
  CC       xmlwriter.lo
  CC       legacy.lo
  CC       chvalid.lo
  CC       pattern.lo
  CC       xmlsave.lo
  CC       xmlmodule.lo
  CC       schematron.lo
  CC       xzlib.lo
In file included from /opt/chefdk/embedded/include/lzma.h:281:0,
                 from xzlib.c:37:
/opt/chefdk/embedded/include/lzma/base.h:218:30: warning: comma at end of enumerator list [-Wpedantic]
  LZMA_PROG_ERROR         = 11,
                              ^
  CCLD     libxml2.la
  CC       testdso.lo
  CCLD     testdso.la
  CC       xmllint.o
  CCLD     xmllint
./.libs/libxml2.a(xmlIO.o): In function `xmlGzfileOpen_real':
xmlIO.c:(.text+0xfa9): undefined reference to `gzdopen'
xmlIO.c:(.text+0x1061): undefined reference to `gzopen64'
./.libs/libxml2.a(xmlIO.o): In function `xmlGzfileOpenW':
xmlIO.c:(.text+0x1165): undefined reference to `gzdopen'
xmlIO.c:(.text+0x1206): undefined reference to `gzopen64'
./.libs/libxml2.a(xmlIO.o): In function `xmlGzfileRead':
xmlIO.c:(.text+0x1252): undefined reference to `gzread'
./.libs/libxml2.a(xmlIO.o): In function `xmlGzfileWrite':
xmlIO.c:(.text+0x129a): undefined reference to `gzwrite'
./.libs/libxml2.a(xmlIO.o): In function `xmlGzfileClose':
xmlIO.c:(.text+0x12d1): undefined reference to `gzclose'
./.libs/libxml2.a(xmlIO.o): In function `xmlFreeZMemBuff':
xmlIO.c:(.text+0x15c0): undefined reference to `deflateEnd'
./.libs/libxml2.a(xmlIO.o): In function `xmlCreateZMemBuff':
xmlIO.c:(.text+0x1717): undefined reference to `deflateInit2_'
xmlIO.c:(.text+0x17a2): undefined reference to `crc32'
./.libs/libxml2.a(xmlIO.o): In function `xmlZMemBuffAppend':
xmlIO.c:(.text+0x1b1f): undefined reference to `deflate'
xmlIO.c:(.text+0x1bbe): undefined reference to `crc32'
./.libs/libxml2.a(xmlIO.o): In function `xmlZMemBuffGetContent':
xmlIO.c:(.text+0x1c56): undefined reference to `deflate'
./.libs/libxml2.a(xmlIO.o): In function `__xmlParserInputBufferCreateFilename':
xmlIO.c:(.text+0x2f64): undefined reference to `gzdirect'
./.libs/libxml2.a(nanohttp.o): In function `xmlNanoHTTPFreeCtxt':
nanohttp.c:(.text+0x785): undefined reference to `inflateEnd'
./.libs/libxml2.a(nanohttp.o): In function `xmlNanoHTTPScanAnswer':
nanohttp.c:(.text+0x16f9): undefined reference to `inflateInit2_'
./.libs/libxml2.a(nanohttp.o): In function `xmlNanoHTTPRead':
nanohttp.c:(.text+0x2154): undefined reference to `inflate'
./.libs/libxml2.a(xzlib.o): In function `is_format_lzma':
xzlib.c:(.text+0x703): undefined reference to `lzma_properties_decode'
./.libs/libxml2.a(xzlib.o): In function `xz_head':
xzlib.c:(.text+0xb7f): undefined reference to `lzma_auto_decoder'
xzlib.c:(.text+0xc7b): undefined reference to `inflateInit2_'
xzlib.c:(.text+0x15ed): undefined reference to `inflateReset'
xzlib.c:(.text+0x1601): undefined reference to `crc32'
./.libs/libxml2.a(xzlib.o): In function `xz_decomp':
xzlib.c:(.text+0x182b): undefined reference to `inflate'
xzlib.c:(.text+0x18ed): undefined reference to `lzma_code'
xzlib.c:(.text+0x19af): undefined reference to `crc32'
./.libs/libxml2.a(xzlib.o): In function `__libxml2_xzclose':
xzlib.c:(.text+0x1f57): undefined reference to `lzma_end'
xzlib.c:(.text+0x1f75): undefined reference to `inflateEnd'
collect2: error: ld returned 1 exit status
make[2]: *** [xmllint] Error 1
make[2]: Leaving directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/tkn/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make: *** [all] Error 2

I'm wondering why it even tries to compile nokogiri as it is shipped with chefdk already afaik.

Any ideas?

@danielsdeleo
Copy link
Contributor

This looks like it's an issue with nokogiri itself, not ChefDK, since it's just the compiler bombing on some C header files it doesn't like. With gem install there's a --conservative option to avoid updating dependencies, but I don't know of any similar thing for bundler, it just uses the latest version it can find. Since we only install nokogiri for dependencies, we can't promise to always have the latest version (also a newer version could have been released after our build, which would cause bundler to try to install a newer version).

ChefDK does have libxml so this suggestion from the error output should work:

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

You could also lock your Gemfile to the version of nokogiri included with ChefDK.

@tknerr
Copy link
Contributor Author

tknerr commented Dec 30, 2014

Thanks @danielsdeleo. Locking to nokogiri 1.6.4.1 in the Gemfile resolves the issue.

There must be something else to it though, as the bundle install works on travis-ci with plain ruby though:
https://travis-ci.org/tknerr/sample-toplevel-cookbook/builds/44818639

Just read that nokogiri 1.6.4+ comes with it's own vendored libxml2 and libxslt:
http://www.nokogiri.org/tutorials/installing_nokogiri.html

In the error output above it fails while trying to compile the nokogiri-vendored libxml2. Maybe some missing header files...

@tknerr
Copy link
Contributor Author

tknerr commented Dec 30, 2014

Oh, it was

In short, sudo apt-get install liblzma-dev zlib1g-dev solved the issue

@danielsdeleo
Copy link
Contributor

@kaustubh-d
Copy link

Here is alternate way
PKG_CONFIG_PATH=/opt/chefdk/embedded/lib/pkgconfig bundle install

or just add this env variable to Gemfile
ENV['PKG_CONFIG_PATH'] = '/opt/chefdk/embedded/lib/pkgconfig'
gem 'nokogiri'

https://github.com/3ofcoins/opscode-omnibus-software/blob/master/config/software/chefdk.rb#L38-L43

@guangyu-shi
Copy link

Yes, "sudo apt-get install liblzma-dev zlib1g-dev" solves the issue. Bliss, --G

@stevenhaddox
Copy link

Wow. This was intense, but thanks @kaustubh-d. Your ENV settings was by far the easiest fix :)

@d-led
Copy link

d-led commented Jul 13, 2015

@guangyu-shi thanks! That worked for me

@brucellino
Copy link

@guangyu-shi +1

ksubrama pushed a commit that referenced this issue Jan 11, 2016
Updated lock file to pull in new omnibus-software which includes AIX ope...
@hsato42
Copy link

hsato42 commented Feb 5, 2016

For RHEL7, yum install zlib-devel solved the problem.

@geexican
Copy link

@tknerr this solved it, I'm so new at this that I don't know why or what the problem was but sudo apt-get install liblzma-dev zlib1g-dev solved it

@lamont-granquist
Copy link
Contributor

Lets stop add metoos to this thread. Compiling nokogiri is hard.

By far the easiest thing you can do is pin the exact version of nokogiri in your Gemfile to the version of nokogiri that we ship in the chef-dk that you are using.

gem "nokogiri", "= 1.6.7.2"

^^^ use whatever version /opt/chef/embedded/bin/gem list | egrep nokogiri returns.

The next best solution is to follow @kaustubh-d's recommendation which will cause the nokogiri that you build to link the same as the nokogiri that we ship:

PKG_CONFIG_PATH=/opt/chefdk/embedded/lib/pkgconfig bundle install

or:

or just add this env variable to Gemfile
ENV['PKG_CONFIG_PATH'] = '/opt/chefdk/embedded/lib/pkgconfig'
gem 'nokogiri'

If you don't feel like doing that, then you can attempt to link nokogiri against your system libraries. You'll need to install compilers and build tools, along with the header files for zlib, possibly lzma, and maybe libxml2 and libxslt, along with whatever else might become necessary in the future:

for RHEL/CentOS something like:

yum install gcc make zlib-devel liblzma-devel zlib-devel libxml2-devel libxslt-devel

or for Ubuntu/Debian some variant of:

apt-get install build-essential liblzma-dev zlib1g-dev libxml2-dev libxslt-dev

Pinning nokogiri (at the top) will generally be vastly easier to use and maintain than the other solutions.

@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 17, 2016
@lamont-granquist
Copy link
Contributor

^ note that last idea is pretty bad. if you start building against system libraries you can wind up in a situation where the omnibus ruby binary links against omnibus-installed versions of those libraries but nokogiri pulls in system versions and that can create bad conflicts (see what happens with omnibus ruby linking against omnibus openssl and the gyrations that the postgresql cookbook has to go through in order to link postgres and the pg gem against the embedded version of openssl to avoid that kind of conflict).

TL;DR: either use the version of nokogiri that ships with chefdk, or use PKG_CONFIG_PATH to link against the libraries that ship in chef-dk.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

10 participants