Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation of packaged libxml2 fails when installing nokogiri-1.6.8 to a mounted volume in docker #1510

Closed
TMaYaD opened this issue Jul 11, 2016 · 8 comments

Comments

@TMaYaD
Copy link

TMaYaD commented Jul 11, 2016

If I don't mount the volume, this works fine. But I want to cache the bundle between builds.
Host is OS X. I'm guessing the issue could be either some code searching for some config or file till root of the file system, or user/group mismatch between the running user and mounted volume.

$ ls -la /srv/app/vendor/bundle
total 4
drwxr-xr-x    1 1000     50             102 Jul 11 08:37 .
drwxr-xr-x    3 root     root          4096 Jul 11 14:54 ..
drwxr-xr-x    1 1000     50             102 Jul 11 08:37 ruby
Dockerfile
# Common Image
FROM ruby:2.3.1-alpine

ENV APP_HOME=/srv/app
RUN mkdir -p $APP_HOME
WORKDIR ${APP_HOME}

# Build Image
RUN apk add --no-cache --virtual .build_packages \
      git openssh-client \
      build-base postgresql-dev ruby-dev

COPY Gemfile* ./

VOLUME $APP_HOME/vendor/bundle

CMD bundle install \
      --clean \
      --deployment \
      --without="test development"
/usr/local/bundle/extensions/x86_64-linux/2.3.0-static/nokogiri-1.6.8/gem_make.out
current directory: /usr/local/bundle/gems/nokogiri-1.6.8/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20160711-1-cjs0hl.rb extconf.rb
Using pkg-config version 1.1.7
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.4.

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.4.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4... OK
Running 'configure' for libxml2 2.9.4... OK
Running 'compile' for libxml2 2.9.4... ERROR, review '/usr/local/bundle/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:
========================================================================
encoding.c: In function 'xmlGetEncodingAlias':
encoding.c:1021:20: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration]
         upper[i] = toupper(alias[i]);
                    ^
encoding.c: In function 'xmlIconvWrapper':
encoding.c:1805:22: error: 'ICONV_CONST' undeclared (first use in this function)
     ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
                      ^
encoding.c:1805:22: note: each undeclared identifier is reported only once for each function it appears in
encoding.c:1805:34: error: expected ')' before 'char'
     ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
                                  ^
Makefile:1248: recipe for target 'encoding.lo' failed
make[2]: *** [encoding.lo] Error 1
make[2]: Leaving directory '/usr/local/bundle/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4'
Makefile:1440: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/local/bundle/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4'
Makefile:859: recipe for target 'all' failed
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/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/bundle/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
    from /usr/local/bundle/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
    from /usr/local/bundle/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
    from /usr/local/bundle/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
    from /usr/local/bundle/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
    from extconf.rb:364: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:363:in `block in process_recipe'
    from extconf.rb:262:in `tap'
    from extconf.rb:262:in `process_recipe'
    from extconf.rb:555:in `<main>'

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

  /usr/local/bundle/extensions/x86_64-linux/2.3.0-static/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1
/usr/local/bundle/extensions/x86_64-linux/2.3.0-static/nokogiri-1.6.8/mkmf.log
"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I.     -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 -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized  conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static  -lpthread -ldl -lcrypt -lm   -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I.     -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 -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized    -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

have_library: checking for gzdopen() in -lz... -------------------- yes

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I.     -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 -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lz  -lpthread -ldl -lcrypt -lm   -lc "
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

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I.     -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 -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static  -lpthread -ldl -lcrypt -lm   -lc "
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 */

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

@TMaYaD TMaYaD changed the title Compilation of packaged libxml2 fails when installing nokogiri to a mounted volume in docker Compilation of packaged libxml2 fails when installing nokogiri-1.6.8 to a mounted volume in docker Jul 11, 2016
@Fudoshiki
Copy link

Fudoshiki commented Oct 2, 2016

brew install libxml2
gem install nokogiri

same issue

@flavorjones
Copy link
Member

Can you please provide enough details to reproduce this, please?

The docker image you are using would be the best start, but I'd also like
to see the logs from the failure you're seeing.

On Oct 2, 2016 6:55 PM, "Yuri S." [email protected] wrote:

same issue with libxml2-2.9.4


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1510 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAgDyogDMTFsuG4P2EPueXHpYKD5Z3Eks5qwDZ6gaJpZM4JJdP3
.

@flavorjones
Copy link
Member

Ah, I see OP has info. Not sure why this is a Nokogiri bug, though. Help me understand the rationale of filing it here?

@flavorjones
Copy link
Member

I've gotten Nokogiri to build just fine using the docker image ruby:2.3.1-alpine, and so I'm going to close this issue (after installing lots of packages, admittedly).

I'd really suggest you take a look at other reasons this might be failing; or else provide a bit more information about why you feel this is a Nokogiri bug.

Also, if you care about Alpine support, please consider sending a PR to the installation tutorial: https://github.com/sparklemotion/nokogiri.org-tutorials

@TMaYaD
Copy link
Author

TMaYaD commented Oct 7, 2016

@flavorjones This might not necessarily be a nokogiri bug but I thought someone here would have a better idea about why it's failing.

Like I mentioned in the first post, nokogiri compiles fine unless the bundle target is a mounted volume (and you don't even need a lot of packages for that). The issue is when trying to install with bundler target on a mounted volume as in the dockerfile attached; specifically, this bit:
VOLUME $APP_HOME/vendor/bundle

Can you please try that and let me know what you make of the error log?

@flavorjones
Copy link
Member

@TMaYaD in the past we've seen issues with overlyfs in docker containers. In particular, check out the sequence of #1370#1405moby/moby#19082.

I'm not sure what I can do to help here.

@jaequery
Copy link

@TMaYaD were you able to figure this out? i'm getting the same error as you describe all of a sudden. i've been using mounted volumes fine till now until i needed nokogiri. please help!

@flavorjones
Copy link
Member

@jaequery I'm sorry you're having issues, but unfortunately this issue is closed.

Please open a new issue and provide the debugging information requested in the issue template. Thank you!

@sparklemotion sparklemotion locked as resolved and limited conversation to collaborators Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@flavorjones @TMaYaD @jaequery @Fudoshiki and others