正如标题所说,它似乎并不是因为缺少libxml2或libxslt而失败。我真的不确定如何使的错误。(明白了吗?因为问题在制造过程中?呵呵…)
不管怎样,这是我得到的输出。如有任何意见,不胜感激:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... 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
make
compiling xml_element_content.c
compiling xml_relax_ng.c
compiling xml_cdata.c
compiling xml_sax_parser_context.c
compiling xml_node_set.c
compiling xml_text.c
compiling xml_sax_parser.c
compiling xml_attribute_decl.c
compiling nokogiri.c
nokogiri.c: In function ‘ruby_strdup’:
nokogiri.c:43:31: warning: conversion to ‘size_t’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
compiling xml_entity_reference.c
compiling xml_node.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:184:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xml_xpath_context.o] Error 1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
作为上下文,我昨晚从Ubuntu 12.04升级到12.10。我以前在这个盒子上构建了Nokogiri本地扩展,尽管我不知道它是否是相同的版本。
我还检查了我在第二篇文章中指定的所有软件包"在rails 3.1.0和ubuntu中安装nokogiri 1.5.0错误"。
花了我一些时间来弄清楚如何添加cflags。下面是nokogiri 1.4.7的命令:
sudo gem install nokogiri -v '1.4.7' -- --with-cflags="-Wformat-nonliteral -Wno-format-security"
如果你想安装Nokogiri <1.5.4,你会在加固的Debian系统上遇到问题,比如Ubuntu 12。
关于潜在问题的详细信息在这里:https://github.com/sparklemotion/nokogiri/issues/680
你应该能够升级到1.5.4或更高版本并且安装没有这个问题。
或者,您应该能够在gem安装时设置CFLAGS环境变量以包含字符串:
-Wno-error=format-security
或
-Wformat-nonliteral -Wno-format-security
祝你好运!
您是否尝试过为nokogiri安装以下依赖项??
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
这可能是由于这个bug导致的> https://leap.se/code/issues/7231
在执行命令前先执行以下命令:
sudo apt-get install zlib1g-dev