【问题标题】:Installing nokogiri - Failed to build gem native extension安装 nokogiri - 无法构建 gem 原生扩展
【发布时间】:2012-12-24 09:10:12
【问题描述】:

在 Ubuntu 12 上安装 Nokogiri 时出现错误:

Installing nokogiri (1.4.4) with native extensions 
Gem::Installer::ExtensionBuildError: 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 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 html_sax_parser_context.c                                                             
compiling xml_io.c                                                                              
compiling xml_entity_reference.c                                                                
compiling xml_schema.c                                                                          
compiling xml_element_content.c                                                                 
compiling xml_reader.c                                                                          
compiling xml_sax_push_parser.c                                                                 
compiling xml_sax_parser.c                                                                      
compiling xslt_stylesheet.c                                                                     
compiling xml_element_decl.c                                                                    
compiling xml_node.c                                                                            
compiling xml_cdata.c                                                                           
compiling xml_processing_instruction.c
compiling xml_entity_decl.c
compiling xml_attribute_decl.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 /home/alex/.bundler/tmp/22194/gems/nokogiri-1.4.4 for inspection.
Results logged to /home/alex/.bundler/tmp/22194/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.4.4), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.4.4'` succeeds before bundling.

我已经安装了 libxslt-dev 和 libxml2-dev,但是正如你所见,它没有帮助。

我该如何解决?

【问题讨论】:

标签: ruby-on-rails ruby gem nokogiri


【解决方案1】:

我在尝试在 ubuntu 13.04 上安装 bigbluebutton 时偶然发现

我通过这个技巧解决了它来编译恢复系统范围内的 -Wformat-security gcc 标志

小心第一个rm。它会破坏你的整个系统!!

rm /usr/bin/gcc
nano /usr/bin/gcc
    ## contents of /usr/bin/gcc
    #!/bin/sh
    gcc-4.7 $* -Wno-format-security
    ## save and exit
chmod u+x /usr/bin/gcc
gem install nokogiri -v '1.4.4'

【讨论】:

    【解决方案2】:

    您需要 1.4.4 而不是最新的 1.5.6 是否有特定原因?否则我建议升级。

    Nokogiri changelog 表明他们在 1.5.4 中修复了这个问题:

    在强化的 Debian 系统上构建支持,该系统使用 -Werror=format-security。 #680.

    【讨论】:

    • 没有理由。但是,也有错误sudo gem install nokogiri Building native extensions. This could take a while... Successfully installed nokogiri-1.5.6 1 gem installed Installing ri documentation for nokogiri-1.5.6... Installing RDoc documentation for nokogiri-1.5.6... alex@ubuntu:~/Documents/prj/rails3_prj$ bundle show nokogiri Could not find nokogiri-1.4.4 in any of the sources
    【解决方案3】:

    @Confusion 有正确的想法。

    Bundler 可能在 Gemfile 和/或 Gemfile.lock 中锁定为 nokogiri-1.4.4。 @Confusion 对运行包更新的回答应该允许您的 Ruby Bundler 环境使用成功安装的 nokogiri-1.5.6。

    【讨论】:

      猜你喜欢
      • 2013-04-08
      • 1970-01-01
      • 2012-09-15
      • 2014-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-02
      • 2016-01-17
      相关资源
      最近更新 更多