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

Nokogiri fails to build with latest ruby:2.2.3 docker image #1370

Closed
adrienkohlbecker opened this issue Nov 6, 2015 · 35 comments
Closed

Nokogiri fails to build with latest ruby:2.2.3 docker image #1370

adrienkohlbecker opened this issue Nov 6, 2015 · 35 comments
Milestone

Comments

@adrienkohlbecker
Copy link

Hello,

The following command: docker pull ruby:2.2.3 && docker run -t -i ruby:2.2.3 gem install nokogiri -v '1.6.6.2' results in an error.
That was not the case a few days ago, so I suspect this commit fro two days ago on the base image may be at fault, but I've not been able to confirm it.

Here is the build log:

➜  ~  docker pull ruby:2.2.3 && docker run -t -i --rm ruby:2.2.3 gem install nokogiri -v '1.6.6.2'
Pulling repository docker.io/library/ruby
f08537117c4d: Download complete
575489a51992: Download complete
6845b83c79fb: Download complete
f9fffdafe16d: Download complete
d63502d4fbd8: Download complete
a3d4ddaffb90: Download complete
df231b622270: Download complete
3802d6035798: Download complete
c314b7cf3e15: Download complete
e9311cad9737: Download complete
8825dcf66d36: Download complete
34e5c4779386: Download complete
3b178d645c21: Download complete
177675c40a08: Download complete
e553b9534450: Download complete
2defd8698c56: Download complete
fb515cf11884: Download complete
Status: Image is up to date for ruby:2.2.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20151106-1-o83i7k.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building 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-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/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... OK
Running 'install' for libxml2 2.9.2... OK
Activating libxml2 2.9.2 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxml2/2.9.2)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.28
with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.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
************************************************************************
Extracting libxslt-1.1.28.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxslt/1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0014-Fix-for-bug-436589.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch...
Running 'patch' for libxslt 1.1.28... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile

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.2.0-static/nokogiri-1.6.6.2/mkmf.log

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR="
compiling xml_dtd.c
compiling xml_schema.c
compiling xml_attr.c
compiling xml_reader.c
compiling html_document.c
compiling xml_comment.c
compiling xml_encoding_handler.c
compiling xml_sax_parser_context.c
compiling xml_io.c
compiling xml_element_content.c
compiling xml_sax_parser.c
compiling xml_cdata.c
compiling xml_libxml2_hacks.c
compiling xml_node.c
xml_node.c: In function 'reparent_node_with':
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
     switch (parent->type) {
     ^
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
compiling xml_node_set.c
xml_node_set.c: In function 'dealloc_namespace':
xml_node_set.c:9:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->href);
             ^
xml_node_set.c:11:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->prefix);
             ^
compiling html_sax_parser_context.c
compiling xml_attribute_decl.c
compiling nokogiri.c
compiling xml_processing_instruction.c
compiling html_sax_push_parser.c
compiling xml_namespace.c
compiling xml_relax_ng.c
compiling html_entity_lookup.c
compiling xml_text.c
compiling xml_entity_reference.c
compiling xslt_stylesheet.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./xslt_stylesheet.h:4,
                 from xslt_stylesheet.c:1:
xslt_stylesheet.c: In function 'initFunc':
xslt_stylesheet.c:217:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
xslt_stylesheet.c: In function 'shutdownFunc':
xslt_stylesheet.c:230:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
compiling xml_element_decl.c
compiling xml_document.c
xml_document.c: In function 'set_encoding':
xml_document.c:182:12: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       free((char *) doc->encoding); /* this may produce a gcc cast warning */
            ^
xml_document.c: In function 'canonicalize':
xml_document.c:537:15: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       ns[i] = (xmlChar*) ptr;
               ^
compiling xml_sax_push_parser.c
compiling xml_xpath_context.c
compiling xml_entity_decl.c
compiling xml_syntax_error.c
compiling html_element_description.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./html_element_description.h:4,
                 from html_element_description.c:1:
html_element_description.c: In function 'get_description':
html_element_description.c:252:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
   return Data_Wrap_Struct(klass, 0, 0, (void *)description);
                                        ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1028:35: note: in definition of macro 'Data_Wrap_Struct'
     rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
                                   ^
compiling xml_document_fragment.c
linking shared-object nokogiri/nokogiri.so
Cleaning files only used during build.
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports
rmdir -p /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ports

No such file or directory - getcwd

Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
@larskanis
Copy link
Member

@adrienkohlbecker It looks differently for me (on Ubuntu-15.04):

lars@netzbuch:~/comcard/nokogiri$ docker run -it ruby:2.2.3 env MAKE="nice make -j2" gem install nokogiri                                                                           
Unable to find image 'ruby:2.2.3' locally                                                                                                                                           
2.2.3: Pulling from ruby                                                                                                                                                            
575489a51992: Pull complete 
6845b83c79fb: Pull complete 
f9fffdafe16d: Pull complete 
d63502d4fbd8: Pull complete 
a3d4ddaffb90: Pull complete 
df231b622270: Pull complete 
3802d6035798: Pull complete 
c314b7cf3e15: Pull complete 
e9311cad9737: Pull complete 
8825dcf66d36: Pull complete 
34e5c4779386: Pull complete 
3b178d645c21: Pull complete 
177675c40a08: Pull complete 
e553b9534450: Pull complete 
2defd8698c56: Pull complete 
fb515cf11884: Pull complete 
f08537117c4d: Pull complete 
ruby:2.2.3: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:e68d8d7bb9e2024526656aaf13cabab66b10e52e5f8ca1b1731a161e64a83739
Status: Downloaded newer image for ruby:2.2.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.6.2
2 gems installed

lars@netzbuch:~/comcard/nokogiri$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.3.3
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.3.3
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64
lars@netzbuch:~/comcard/nokogiri$ 

@allenwei
Copy link

I have same problem, it works when I downgrade rubygems to 2.4.8

@hatchan
Copy link

hatchan commented Nov 11, 2015

We're experiencing the same issue for some of our users, though I'm not able to reproduce it on my local machine.

This is from one of our build machines:

$ docker pull ruby && docker run -t -i --rm ruby:2.2.3 gem install nokogiri -v '1.6.6.2'
latest: Pulling from ruby

575489a51992: Already exists 
6845b83c79fb: Already exists 
f9fffdafe16d: Already exists 
d63502d4fbd8: Already exists 
a3d4ddaffb90: Already exists 
df231b622270: Already exists 
3802d6035798: Already exists 
c314b7cf3e15: Already exists 
e9311cad9737: Already exists 
8825dcf66d36: Already exists 
34e5c4779386: Already exists 
3b178d645c21: Already exists 
177675c40a08: Already exists 
e553b9534450: Already exists 
2defd8698c56: Already exists 
fb515cf11884: Already exists 
f08537117c4d: Already exists 
Digest: sha256:3c285fd48293e33169df713445e1b8a83eadf02dcc4c2b8908c8af93e061f120
Status: Image is up to date for ruby:latest
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20151111-1-lcot8f.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building 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-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/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... OK
Running 'install' for libxml2 2.9.2... OK
Activating libxml2 2.9.2 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxml2/2.9.2)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.28
with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.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
************************************************************************
Extracting libxslt-1.1.28.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxslt/1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0014-Fix-for-bug-436589.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch...
Running 'patch' for libxslt 1.1.28... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile

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.2.0-static/nokogiri-1.6.6.2/mkmf.log

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR="
compiling html_entity_lookup.c
compiling html_document.c
compiling html_sax_parser_context.c
compiling xml_document.c
xml_document.c: In function 'set_encoding':
xml_document.c:182:12: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       free((char *) doc->encoding); /* this may produce a gcc cast warning */
            ^
xml_document.c: In function 'canonicalize':
xml_document.c:537:15: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       ns[i] = (xmlChar*) ptr;
               ^
compiling xml_node.c
xml_node.c: In function 'reparent_node_with':
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
     switch (parent->type) {
     ^
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
compiling xml_entity_decl.c
compiling xml_syntax_error.c
compiling xml_namespace.c
compiling xml_schema.c
compiling xml_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling nokogiri.c
compiling xml_attr.c
compiling xml_attribute_decl.c
compiling xml_reader.c
compiling html_element_description.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./html_element_description.h:4,
                 from html_element_description.c:1:
html_element_description.c: In function 'get_description':
html_element_description.c:252:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
   return Data_Wrap_Struct(klass, 0, 0, (void *)description);
                                        ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1028:35: note: in definition of macro 'Data_Wrap_Struct'
     rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
                                   ^
compiling html_sax_push_parser.c
compiling xml_dtd.c
compiling xml_cdata.c
compiling xml_sax_parser.c
compiling xml_document_fragment.c
compiling xml_encoding_handler.c
compiling xml_io.c
compiling xml_comment.c
compiling xml_node_set.c
xml_node_set.c: In function 'dealloc_namespace':
xml_node_set.c:9:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->href);
             ^
xml_node_set.c:11:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->prefix);
             ^
compiling xml_relax_ng.c
compiling xml_processing_instruction.c
compiling xml_libxml2_hacks.c
compiling xml_text.c
compiling xml_element_content.c
compiling xml_element_decl.c
compiling xml_entity_reference.c
compiling xslt_stylesheet.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./xslt_stylesheet.h:4,
                 from xslt_stylesheet.c:1:
xslt_stylesheet.c: In function 'initFunc':
xslt_stylesheet.c:217:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
xslt_stylesheet.c: In function 'shutdownFunc':
xslt_stylesheet.c:230:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
compiling xml_xpath_context.c
linking shared-object nokogiri/nokogiri.so
Cleaning files only used during build.
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports
rmdir -p /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ports

No such file or directory - getcwd

Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.2.0-static/nokogiri-1.6.6.2/gem_make.out

$ docker info
Containers: 4
Images: 1212
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
...

$ docker version 
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2-dirty
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 7c8fca2-dirty
OS/Arch (server): linux/amd64

This is from my local machine:

$ docker pull ruby && docker run -t -i --rm ruby:2.2.3 gem install nokogiri -v '1.6.6.2' 
Using default tag: latest
latest: Pulling from library/ruby
Digest: sha256:3c285fd48293e33169df713445e1b8a83eadf02dcc4c2b8908c8af93e061f120
Status: Image is up to date for ruby:latest
Unable to find image 'ruby:2.2.3' locally
2.2.3: Pulling from library/ruby
Digest: sha256:e68d8d7bb9e2024526656aaf13cabab66b10e52e5f8ca1b1731a161e64a83739
Status: Downloaded newer image for ruby:2.2.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.6.2
2 gems installed

$ docker info
Containers: 5
Images: 358
Server Version: 1.9.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 374
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.2.0-16-generic
Operating System: Ubuntu 15.10
CPUs: 8
Total Memory: 31.38 GiB

$ docker version
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:54:53 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:54:53 UTC 2015
 OS/Arch:      linux/amd64

I can also confirm that downgrading to RubyGems 2.4.8 does not have the issue.

My guess it has something to do with the Docker version or the storage driver.

@allenwei
Copy link

Can you try
docker pull ruby && docker run -t -i --rm ruby:2.2.3 gem update --system '2.4.8' && gem install nokogiri -v '1.6.6.2'

@hatchan
Copy link

hatchan commented Nov 11, 2015

@allenwei that code snippet won't work as the latter part will be run on the host. I did try the following:

$ docker pull ruby && docker run -t -i --rm ruby /bin/bash
latest: Pulling from ruby
575489a51992: Already exists 
6845b83c79fb: Already exists 
f9fffdafe16d: Already exists 
d63502d4fbd8: Already exists 
a3d4ddaffb90: Already exists 
df231b622270: Already exists 
3802d6035798: Already exists 
c314b7cf3e15: Already exists 
e9311cad9737: Already exists 
8825dcf66d36: Already exists 
34e5c4779386: Already exists 
3b178d645c21: Already exists 
177675c40a08: Already exists 
e553b9534450: Already exists 
2defd8698c56: Already exists 
fb515cf11884: Already exists 
f08537117c4d: Already exists 
Digest: sha256:3c285fd48293e33169df713445e1b8a83eadf02dcc4c2b8908c8af93e061f120
Status: Image is up to date for ruby:latest

root@85012f490d75:/# gem update --system '2.4.8'
Updating rubygems-update
Fetching: rubygems-update-2.4.8.gem (100%)
Successfully installed rubygems-update-2.4.8
Installing RubyGems 2.4.8
RubyGems 2.4.8 installed



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

RubyGems installed the following executables:
    /usr/local/bin/gem

RubyGems system software updated

root@85012f490d75:/# gem install nokogiri -v '1.6.6.2'
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
sh: 0: getcwd() failed: No such file or directory
Successfully installed nokogiri-1.6.6.2
2 gems installed

@tobstarr
Copy link

Same issue here

$ docker run --rm -t -i ruby:2.2.3 gem install nokogiriFetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20151112-1-ynq4bo.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building 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-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/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... OK
Running 'install' for libxml2 2.9.2... OK
Activating libxml2 2.9.2 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxml2/2.9.2)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.28
with the following patches applied:
        - 0001-Adding-doc-update-related-to-1.1.28.patch
        - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
        - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
        - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
        - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
        - 0007-Separate-function-for-predicate-matching-in-patterns.patch
        - 0008-Fix-direct-pattern-matching.patch
        - 0009-Fix-certain-patterns-with-predicates.patch
        - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
        - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
        - 0014-Fix-for-bug-436589.patch
        - 0015-Fix-mkdir-for-mingw.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
************************************************************************
Extracting libxslt-1.1.28.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxslt/1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0014-Fix-for-bug-436589.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch...
Running 'patch' for libxslt 1.1.28... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /usr/local/bundle/gems/nokogiri-1.6.6.2/ports/x86_64-pc-linux-gnu/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile

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.2.0-static/nokogiri-1.6.6.2/mkmf.log

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri
make "DESTDIR="
compiling html_document.c
compiling html_entity_lookup.c
compiling html_sax_push_parser.c
compiling xml_element_decl.c
compiling nokogiri.c
compiling xml_attribute_decl.c
compiling xml_dtd.c
compiling xml_processing_instruction.c
compiling xml_node.c
xml_node.c: In function 'reparent_node_with':
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:168:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:186:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_NODE' not handled in switch [-Wswitch]
       switch (reparentee->type) {
       ^
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCUMENT_FRAG_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_HTML_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:197:7: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_CDATA_SECTION_NODE' not handled in switch [-Wswitch]
     switch (parent->type) {
     ^
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_PI_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_COMMENT_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCUMENT_TYPE_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NOTATION_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DTD_NODE' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ELEMENT_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ATTRIBUTE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_ENTITY_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_NAMESPACE_DECL' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_START' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_XINCLUDE_END' not handled in switch [-Wswitch]
xml_node.c:165:5: warning: enumeration value 'XML_DOCB_DOCUMENT_NODE' not handled in switch [-Wswitch]
compiling xml_element_content.c
compiling xml_syntax_error.c
compiling xml_sax_parser.c
compiling xml_reader.c
compiling xml_attr.c
compiling html_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling xml_encoding_handler.c
compiling xml_node_set.c
xml_node_set.c: In function 'dealloc_namespace':
xml_node_set.c:9:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->href);
             ^
xml_node_set.c:11:13: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     xmlFree((xmlChar *)ns->prefix);
             ^
compiling xml_xpath_context.c
compiling xml_entity_decl.c
compiling xml_schema.c
compiling xml_io.c
compiling xslt_stylesheet.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./xslt_stylesheet.h:4,
                 from xslt_stylesheet.c:1:
xslt_stylesheet.c: In function 'initFunc':
xslt_stylesheet.c:217:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
xslt_stylesheet.c: In function 'shutdownFunc':
xslt_stylesheet.c:230:21: warning: passing argument 1 of 'rb_data_object_get' makes integer from pointer without a cast
     Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
                     ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1044:41: note: in definition of macro 'Data_Get_Struct'
     ((sval) = (type*)rb_data_object_get(obj))
                                         ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1189:1: note: expected 'VALUE' but argument is of type 'void *'
 rb_data_object_get(VALUE obj)
 ^
compiling html_element_description.c
In file included from /usr/local/include/ruby-2.2.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./html_element_description.h:4,
                 from html_element_description.c:1:
html_element_description.c: In function 'get_description':
html_element_description.c:252:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
   return Data_Wrap_Struct(klass, 0, 0, (void *)description);
                                        ^
/usr/local/include/ruby-2.2.0/ruby/ruby.h:1028:35: note: in definition of macro 'Data_Wrap_Struct'
     rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
                                   ^
compiling xml_cdata.c
compiling xml_sax_parser_context.c
compiling xml_namespace.c
compiling xml_comment.c
compiling xml_relax_ng.c
compiling xml_document.c
xml_document.c: In function 'set_encoding':
xml_document.c:182:12: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       free((char *) doc->encoding); /* this may produce a gcc cast warning */
            ^
xml_document.c: In function 'canonicalize':
xml_document.c:537:15: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
       ns[i] = (xmlChar*) ptr;
               ^
compiling xml_libxml2_hacks.c
compiling xml_entity_reference.c
compiling xml_document_fragment.c
compiling xml_text.c
linking shared-object nokogiri/nokogiri.so
Cleaning files only used during build.
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports
rmdir -p /usr/local/bundle/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu
rm -rf /usr/local/bundle/gems/nokogiri-1.6.6.2/ports

No such file or directory - getcwd

Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.2.0-static/nokogiri-1.6.6.2/gem_make.out

$ docker info
Containers: 97
Images: 567
Server Version: 1.9.0
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.2.0-16-generic
Operating System: Ubuntu 15.10
CPUs: 4
Total Memory: 7.682 GiB
Name: tobias-x220
ID: 6KGX:AGSX:NXMP:GVC4:J4ZK:W5PT:XUNT:7MWH:CR6X:AWKQ:G6OM:QHRH
WARNING: No swap limit support

$ docker version
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      linux/amd64

Looks like it is related to the overlay driver.

@tobstarr
Copy link

Also: downgrading rubygems solves the issue for me

@tobstarr
Copy link

We have the same issue with docker 1.8.1 on this box

$ docker info
Containers: 10
Images: 129
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.0-25-generic
Operating System: Ubuntu 15.04
CPUs: 8
Total Memory: 31.16 GiB
Name: Ubuntu-1504-vivid-64-minimal
ID: RAFX:ZWR3:7DC4:VWDK:6IST:7267:H7I5:E6K3:FZX5:LSIG:GLZC:DAJV
WARNING: No swap limit support

$ docker version
Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      linux/amd64

@tianon
Copy link

tianon commented Nov 20, 2015

Do you think this might actually be a bug specific to the new version of rubygems? Are there any other native gems that are affected by the interaction with overlayfs described here?

@jvshahid
Copy link
Member

this seems to be fixed with the latest version 1.6.6.4, output from my machine:

$ sudo docker pull ruby:2.2.3 && sudo docker run -t -i ruby:2.2.3 gem install nokogiri -v '1.6.6.4'
[sudo] password for jvshahid: 
2.2.3: Pulling from library/ruby

a719479f5894: Pull complete 
91bac885982d: Pull complete 
8ca313dfa777: Pull complete 
66769fc86d84: Pull complete 
419547a27787: Pull complete 
fd4340e76c4d: Pull complete 
c3a7b9c6d33c: Pull complete 
01b675475dae: Pull complete 
ba00762675d7: Pull complete 
07ff586b4a3c: Pull complete 
2480b64c1d5d: Pull complete 
a8497031f086: Pull complete 
226b1fd35b89: Pull complete 
2a893a9c2c2b: Pull complete 
9be99e52d141: Pull complete 
11704367fbe6: Pull complete 
6ec3b2e516f4: Pull complete 
Digest: sha256:7ecdacd83b4cdd9e374bdc81544977de1857073f633b2b13f3f12de7b21027e1
Status: Downloaded newer image for ruby:2.2.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.4.gem (100%)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.6.4
2 gems installed

I'll go ahead and close this issue.

@adrienkohlbecker
Copy link
Author

@jvshahid I'm still getting the same issue with 1.6.6.4

@tobstarr
Copy link

@jvshahid still the same issue here, as I mentioned before, it is probably more a docker and/or overlay fs issue then a nokogiri one

@tobstarr
Copy link

I just tested it with docker 1.9.1, same issue

@jvshahid
Copy link
Member

I'm not sure what's going on. I tested installing nokogiri 1.6.6.2 and 1.6.6.4 using docker 1.9.1 and can't reproduce the issue. Can someone provide a way to reproduce this issue ? May be the output from uname -a and the name and version of the distro you are using.

@jvshahid jvshahid reopened this Nov 22, 2015
@adrienkohlbecker
Copy link
Author

Here is some information, I'm not sure on what I can do to help, let me know

➜  vagrant@dev ~ $ uname -a
Linux dev 3.19.0-33-generic #38~14.04.1-Ubuntu SMP Fri Nov 6 18:17:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
➜  vagrant@dev ~ $ docker info
Containers: 3
Images: 346
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.0-33-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 4
Total Memory: 3.067 GiB
Name: dev
ID: 5JEW:UGQL:IWLI:MQZU:YE3C:NKCT:67U5:GUSW:GUUB:W3MC:Q2UV:ML2O
➜  vagrant@dev ~ $ docker version
Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:35:49 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:35:49 UTC 2015
 OS/Arch:      linux/amd64
➜  vagrant@dev ~ $ cat /etc/default/docker
# Docker Upstart and SysVinit configuration file

DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -s overlay --icc=false --log-level="info" --iptables --default-ulimit nproc=1024:2048 --default-ulimit nofile=10000:20000"

Also, this is a Vagrant VM running under Parallels Desktop, but I was able to reproduce the issue on AWS with the same config (both machines provisioned the same way).

@larskanis
Copy link
Member

I can reproduce this, after switching from aufs to overlayfs. Same error as above.

Interestingly other gems with extensions work (I tried ffi and tiny_tds successfully) and gem inst nokogiri -- --disable-clean works as well.

@flavorjones
Copy link
Member

I'm sorry, I can't reproduce this:

~ $ docker pull ruby:2.2.3 && docker run -t -i ruby:2.2.3 gem install nokogiri -v '1.6.6.2'
2.2.3: Pulling from library/ruby
1565e86129b8: Pull complete 
a604b236bcde: Pull complete 
5822f840e16b: Pull complete 
107e487a8c94: Pull complete 
a8b24eb79c37: Pull complete 
812a155e2263: Pull complete 
4016a026cc95: Pull complete 
0b976a94ca21: Pull complete 
55b058117d96: Pull complete 
d102545addc5: Pull complete 
a9083e14783b: Pull complete 
6db189aaf402: Pull complete 
e2aceecfcf13: Pull complete 
103d36ce7a12: Pull complete 
b68ebb122109: Pull complete 
6b92e3f34f17: Pull complete 
a930a50e60f8: Pull complete 
Digest: sha256:e6e4a55c272d3c01c7833a762ea6747f37e12a1728ddf057155880d31ed17298
Status: Downloaded newer image for ruby:2.2.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.6.2
2 gems installed

If the current claim is that the filesystem being used affects Nokogiri installation, then I'd suggest it's not a Nokogiri problem to solve.

If there are objections to closing this issue, then please let me know. I'll look into it if someone can convince me with a compelling argument that this is a Nokogiri issue.

@connorshea
Copy link

I'm getting this same issue on our CI server with Codeship. Ruby 2.3.0 and nokogiri 1.6.7.1.

Anyone else running into this problem can add the line bundle config build.nokogiri --use-system-libraries to their Test Settings on Codeship, that fixed it for me.

@sfcgeorge
Copy link

I had the same issue on Codeship CI and confirm that the above --use-system-libraries fix worked for me, though that feels like a nasty hack.

The same version of Nokogiri (1.6.7.1) worked for me before in the same Codeship environment (which is standard Ubuntu 14.04 "Every build gets a new completely clean virtual machine"). The only thing that I changed was my version of Ruby to 2.3 so surely it is a Nokogiri issue, caused by some change in Ruby?

@flavorjones
Copy link
Member

As I mentioned in my Nov 29 comment, I can't reproduce this. Unless someone can help me reproduce it, I'm going to close it.

Speculation that this is "surely a Nokogiri issue" is meaningless without a reproducible test case, I'm sorry. Help me help you, everyone.

@larskanis
Copy link
Member

@flavorjones You need to switch docker to overlayfs. The issue doesn't exist with aufs. On Ubuntu-15.04 it should then be reproducible with:

docker pull ruby:2.2.3 && docker run -t -i ruby:2.2.3 gem install nokogiri -v '1.6.6.2'

Both --use-system-libraries and --disable-clean can be used as a workaround.

Overlayfs and the docker support for it, are still quite new, so that there are a lot of other issues next to nokogiri, that are surely addressed quickly. That's why I didn't investigate it in depth, so far.

@tianon
Copy link

tianon commented Jan 5, 2016

As I've mentioned over in docker-library/ruby#55 (comment), I think this overlayfs failure is really introduced by rubygems (whether it's a bug in rubygems or nokogiri remains to be seen, but it's odd that nokogiri appears to be the only gem affected). I think a bisect of rubygems changes from 2.4.8 to 2.5.0 by someone who can reproduce the failure on their system is our best bet for narrowing this down further.

@larskanis
Copy link
Member

@tianon I narrowed it down to the kernel calls that fail on overlayfs and opened a new issue on docker: moby/moby#19082

... and opened a proposal to how we can avoid this issue in nokogiri: #1405

larskanis added a commit to larskanis/nokogiri that referenced this issue Jan 5, 2016
Deletion of these empty directories is flawed on docker with overlayfs,
so we better avoid it.
The build artifacts are still removed after gem install.

This fixes nokogiri issue sparklemotion#1370 .
For further details to the root issue see: moby/moby#19082
@tobstarr
Copy link

tobstarr commented Jan 6, 2016

@larskanis thank you very much!

@flavorjones
Copy link
Member

Closing this, since Lars's change is in master and will be in Nokogiri v1.6.8. If anyone desperately needs an RC let me know and I can cut 1.6.8.rc2.

@balinterdi
Copy link

I'd like to ask for a rc release to be cut as this bug probably keeps our Rails project to be properly built on our CI server. Thank you.

@flavorjones
Copy link
Member

@balinterdi Curious why you used the work "probably" in that sentence. Are you not sure what's going on? I wouldn't recommend using an RC in production, so please think hard about whether your need is desperate.

Keep in mind that this bug is not a Nokogiri bug, we're working around an overlayfs bug with this commit. You could also not use overlayfs in your Docker container to avoid the bug.

Regardless, I'll cut an RC today and everyone can decide for themselves whether to use it.

@balinterdi
Copy link

@flavorjones I used "probably" because it fails on the CI server where they use overlayfs but it does not fail for me locally (more precisely, it fails with something else). Good point about not using an RC in production, and thank you for releasing a new version, I can still make the call after that.

@flavorjones
Copy link
Member

v1.6.8.rc2 has been unleashed upon the universe. have fun.

@antoineco
Copy link

I can confirm what @connorshea said, nokogiri >1.6.7 will throw the same error:

  • on Ruby 2.3.0 (not on older versions)
  • with pre-installed libxml2-dev and libxslt1-dev (works without)
  • as unprivileged user only (works as root)

Sounds like a conflict between the system libs and the packaged ones. --use-system-libraries works but this is not a solution, just a workaround.

@flavorjones if you want to reproduce this, use this Dockerfile:

FROM debian:jessie

# install system dependencies
RUN apt-get update \
  && apt-get install -y \
    curl \
    libxml2-dev \
    libxslt1-dev \
    liblzma-dev

# install rvm
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
  && curl -sL https://get.rvm.io | bash -s head

# install Ruby
RUN bash -il -c "rvm install 2.2.4"
RUN bash -il -c "rvm install 2.3.0"

# create non-root user
RUN useradd -m foo \
  && usermod -aG rvm foo
USER foo

Extra guidance for people not familiar with Docker.

Build the image:

docker build -t rvmtest .

Install nokogiri using either Ruby version:

docker run --rm -it rvmtest bash -il -c "rvm use 2.2.4 && gem install -V nokogiri"
#works
docker run --rm -it rvmtest bash -il -c "rvm use 2.3.0 && gem install -V nokogiri"
#fails

@flavorjones
Copy link
Member

@antoineco please read previous comments. This is fixed in the 1.6.8 release candidate.

@antoineco
Copy link

Sorry 🙏 I read it but wasn't sure if this actually covers Ruby 2.3, since I could never reproduce on 2.2

Thanks for the quick answer and confirmation!

@joe1chen
Copy link

I also ran into this problem and using the 1.6.8 release candidate fixed my issue.

@SamSaffron
Copy link

I just hit this and can confirm 1.6.8.rc3 fixes, hopefully it is released soon ❤️

@mpalmer
Copy link

mpalmer commented Jun 2, 2016

Agreed, a final release of 1.6.8 would be very nice for me, too, since I just bumped up against this on a container build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests