【问题标题】:nokogiri not installing in ruby 2.7.1 centos 7.2nokogiri 没有安装在 ruby​​ 2.7.1 centos 7.2 中
【发布时间】:2020-11-06 09:14:53
【问题描述】:
Getting below error when installing nokogiri i tried

install -y make gcc rpm-build ruby​​-devel zlib-devel
宝石安装 nokogiri

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

    current directory: /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/ext/nokogiri
/usr/local/rvm/rubies/ruby-2.7.1/bin/ruby -I /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r ./siteconf20200716-18065-1jmltdp.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.10
with the following patches applied:
        - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
        - 0002-Remove-script-macro-support.patch
        - 0003-Update-entities-to-remove-handling-of-ssi.patch
        - 0004-libxml2.la-is-in-top_builddir.patch
        - 0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.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.10.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.10... OK
Running patch with /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch... OK
Running patch with /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/patches/libxml2/0002-Remove-script-macro-support.patch... OK
Running patch with /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/patches/libxml2/0003-Update-entities-to-remove-handling-of-ssi.patch... OK
Running patch with /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/patches/libxml2/0004-libxml2.la-is-in-top_builddir.patch... OK
Running patch with /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch... OK
Running 'configure' for libxml2 2.9.10... OK
Running 'compile' for libxml2 2.9.10... OK
Running 'install' for libxml2 2.9.10... OK
Activating libxml2 2.9.10 (from /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/ports/x86_64-pc-linux-gnu/libxml2/2.9.10)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.34.

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.34.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxslt/1.1.34... OK
Running 'configure' for libxslt 1.1.34... OK
Running 'compile' for libxslt 1.1.34... OK
Running 'install' for libxslt 1.1.34... OK
Activating libxslt 1.1.34 (from /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/ports/x86_64-pc-linux-gnu/libxslt/1.1.34)...
checking for -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

current directory: /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/ext/nokogiri
make "DESTDIR=" clean

current directory: /usr/local/rvm/gems/ruby-2.7.1/gems/nokogiri-1.10.10/ext/nokogiri
make "DESTDIR="
compiling html_document.c
compiling html_element_description.c
compiling html_entity_lookup.c
compiling html_sax_parser_context.c
compiling html_sax_push_parser.c
compiling nokogiri.c
compiling xml_attr.c
compiling xml_attribute_decl.c
compiling xml_cdata.c
compiling xml_comment.c
compiling xml_document.c
xml_document.c: In function ‘dealloc’:
xml_document.c:49:3: warning: passing argument 2 of ‘rb_st_foreach’ from incompatible pointer type [enabled by default]
   st_foreach(node_hash, dealloc_node_i, (st_data_t)doc);
   ^
In file included from /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/intern.h:39:0,
                 from /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/ruby.h:2148,
                 from /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby.h:33,
                 from ./nokogiri.h:33,
                 from ./xml_document.h:4,
                 from xml_document.c:1:
/usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/st.h:141:5: note: expected ‘int (*)(st_data_t,  st_data_t,  st_data_t)’ but argument is of type ‘int (*)(struct xmlNode *, struct xmlNode *, struct xmlDoc *)’
 int rb_st_foreach(st_table *, st_foreach_callback_func *, st_data_t);
     ^
xml_document.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
compiling xml_document_fragment.c
compiling xml_dtd.c
compiling xml_element_content.c
compiling xml_element_decl.c
compiling xml_encoding_handler.c
compiling xml_entity_decl.c
compiling xml_entity_reference.c
compiling xml_io.c
xml_io.c: In function ‘io_read_callback’:
xml_io.c:20:3: warning: passing argument 1 of ‘rb_rescue’ from incompatible pointer type [enabled by default]
   string = rb_rescue(read_check, (VALUE)args, read_failed, 0);
   ^
In file included from /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./xml_io.h:4,
                 from xml_io.c:1:
**/usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/ruby.h:1987:7: note: expected ‘VALUE (*)(VALUE)’ but argument is of type ‘VALUE (*)(VALUE *)’
 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);**
       ^
*xml_io.c:20:3: warning: passing argument 3 of ‘rb_rescue’ from incompatible pointer type [enabled by default]
   string = rb_rescue(read_check, (VALUE)args, read_failed, 0);
   ^*
In file included from /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby.h:33:0,
                 from ./nokogiri.h:33,
                 from ./xml_io.h:4,
                 from xml_io.c:1:
/usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/ruby.h:1987:7: note: expected ‘VALUE (*)(VALUE,  VALUE)’ but argument is of type ‘VALUE (*)(void)’
 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
       ^

xml_io.c:在函数“io_write_callback”中: xml_io.c:47:3:警告:从不兼容的指针类型传递“rb_rescue”的参数 1 [默认启用] 大小 = rb_rescue(write_check, (VALUE)args, write_failed, 0); ^ 在 /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby.h:33:0 包含的文件中, 来自./nokogiri.h:33, 来自./xml_io.h:4, 从 xml_io.c:1: /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/ruby.h:1987:7: 注意:预期为“VALUE ()(VALUE)”,但参数的类型为“VALUE” ()(价值 )' 价值 rb_rescue(价值()(价值),价值,价值()(价值,价值),价值); ^ xml_io.c:47:3:警告:从不兼容的指针类型传递“rb_rescue”的参数 3 [默认启用] 大小 = rb_rescue(write_check, (VALUE)args, write_failed, 0); ^ 在 /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby.h:33:0 包含的文件中, 来自./nokogiri.h:33, 来自./xml_io.h:4, 从 xml_io.c:1: /usr/local/rvm/rubies/ruby-2.7.1/include/ruby-2.7.0/ruby/ruby.h:1987:7: 注意:预期为“VALUE ()(VALUE, VALUE)”,但参数属于类型 ‘值 ()(void)’ 价值 rb_rescue(价值()(价值),价值,价值(*)(价值,价值),价值);

       ^
***xml_io.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
compiling xml_libxml2_hacks.c
compiling xml_namespace.c
compiling xml_node.c
xml_node.c: In function ‘reparent_node_with’:
xml_node.c:304:7: warning: passing argument 1 of ‘xmlFree’ discards ‘const’ qualifier from pointer target type [enabled by default]
       xmlFree(reparentee->ns->prefix);
       ^***
xml_node.c:304:7: note: expected ‘void *’ but argument is of type ‘const xmlChar *’
xml_node.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
compiling xml_node_set.c
compiling xml_processing_instruction.c
compiling xml_reader.c
compiling xml_relax_ng.c
compiling xml_sax_parser.c
compiling xml_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling xml_schema.c
compiling xml_syntax_error.c
compiling xml_text.c
compiling xml_xpath_context.c
compiling xslt_stylesheet.c
xslt_stylesheet.c:112:13: warning: ‘swallow_superfluous_xml_errors’ defined but not used [-Wunused-function]
 static void swallow_superfluous_xml_errors(void * userdata, xmlErrorPtr error, ...)
             ^
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
linking shared-object nokogiri/nokogiri.so
/usr/bin/ld: unrecognized option '--compress-debug-sections=zlib'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
make: *** [nokogiri.so] Error 1

make failed, exit code 2

【问题讨论】:

  • 它没有格式化,但我希望它能给你一些想法
  • 我认为您还需要 libxml-devel 和 libxslt-devel 或其他名称...
  • “它没有被格式化,但我希望它能给出想法”。然后格式化。正确格式化是提出问题和成为社区成员的重要组成部分。请阅读这些内容,然后编辑并改进您的问题:“How do I format my posts...”和“How do I format my code blocks?”。请记住,如果您没有努力很好地提出问题,那么它就不太容易理解,也不太可能得到有用的答案,并且会迫使我们尝试解决它。​​
  • @NickM 我收到消息包 libxml2-devel-2.9.1-6.el7.4.x86_64 已经安装并且最新版本和包 libxslt-devel-1.1.28-5.el7.x86_64 已经已安装和最新版本。所以 libxml2 和 libxlt 最新的包已经存在了。
  • 刚发现nokogiri 1.11.0.rc2正在安装,不知道这个版本是否稳定使用。

标签: ruby-on-rails ruby rubygems nokogiri


【解决方案1】:

出现此错误是因为Centos 7.4 上的默认链接器不支持该选项--compress-debug-sections=zlibCentos 7.8 似乎解决了这个问题。

但如果您无法切换到Centos 7.8,黄金链接器 (ld.gold) 支持该选项。

要启用使用,您可以通过执行类似的操作来覆盖链接器

ln -s /bin/ld.gold ~/bin/ld; PATH=~/bin:$PATH

然后运行需要的命令

【讨论】:

    【解决方案2】:

    就我的 centos 版本而言,/usr/bin/ldbinutils 的一部分,所以我的建议

    $ sudo yum update binutils
    

    帮助了我(而不是完整的操作系统更新)

    【讨论】:

      【解决方案3】:

      我遇到了完全相同的问题。 看来真正的错误是

      /usr/bin/ld: 无法识别的选项'--compress-debug-sections=zlib'

      标志“--compress-debug-sections=zlib”在文件 /usr/local/rvm/gems/ruby-2.7.0/gems/nokogiri-1.10.10/ext/nokogiri/Makefile 中定义。 这个makefile是由mkmf.rb创建的,flags的默认值在这个文件/usr/local/rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/x86_64-linux/rbconfig .rb

      CONFIG["DLDFLAGS"] = "-Wl,--compress-debug-sections=zlib"

      在我将这一行更改为之后

      CONFIG["DLDFLAGS"] = ""

      gem install nokogiri 效果很好

      但我不确定标志“--compress-debug-sections=zlib”的确切功能以及删除它会发生什么

      【讨论】:

        【解决方案4】:

        我的 Centos 版本是 7.6,所有为 nokogiri 提供的解决方案都不起作用。最后我将 centos 更新到 7.8 并且它工作了。我也在其他服务器上尝试使用 centos 7.7 版本,它也适用于 7.7。

        【讨论】:

          猜你喜欢
          • 2016-07-29
          • 1970-01-01
          • 2019-06-22
          • 1970-01-01
          • 1970-01-01
          • 2015-04-09
          • 2011-04-07
          • 2017-10-06
          • 1970-01-01
          相关资源
          最近更新 更多