Ruby 在Ubuntu 12.10上安装Nokogiri(1.5.2)时出现问题

Ruby 在Ubuntu 12.10上安装Nokogiri(1.5.2)时出现问题,ruby,ubuntu,gem,nokogiri,Ruby,Ubuntu,Gem,Nokogiri,我正在运行Ubuntu 12.10,当我运行命令时: bundle install 我得到: Installing nokogiri (1.5.2) 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

我正在运行Ubuntu 12.10,当我运行命令时:

bundle install
我得到:

Installing nokogiri (1.5.2) 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 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_processing_instruction.c
compiling xml_node.c
compiling html_entity_lookup.c
compiling xml_syntax_error.c
compiling xml_document.c
xml_document.c: In function ‘set_encoding’:
xml_document.c:159:12: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
xml_document.c: In function ‘canonicalize’:
xml_document.c:505:15: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
compiling xml_encoding_handler.c
compiling xml_namespace.c
xml_namespace.c: In function ‘prefix’:
xml_namespace.c:14:13: warning: variable ‘doc’ set but not used [-Wunused-but-set-variable]
xml_namespace.c: In function ‘href’:
xml_namespace.c:33:13: warning: variable ‘doc’ set but not used [-Wunused-but-set-variable]
compiling xml_entity_decl.c
compiling xml_attribute_decl.c
compiling xml_comment.c
compiling xml_dtd.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:189: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/site/.bundler/tmp/19240/gems/nokogiri-1.5.2 for inspection.
Results logged to /home/site/.bundler/tmp/19240/gems/nokogiri-1.5.2/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.2'` succeeds before bundling.
当我跑步时:

gem install nokogiri -v '1.5.2'
我得到:

site@ubuntu:~/Documents/shopqi$ gem install nokogiri -v '1.5.2'
malloc_limit=60000000 (8000000)
free_min=50000 (4096)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.5.2
1 gem installed
Installing ri documentation for nokogiri-1.5.2...
Installing RDoc documentation for nokogiri-1.5.2...
site@ubuntu:~/Documents/shopqi$
没有错误,但是如果我再次尝试
bundle安装
,我会得到一个错误,即没有安装Nokogiri

运行sudo gem install nokogiri-v'1.5.2'后,gem_make.out的内容是:

/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_processing_instruction.c
compiling xml_node.c
compiling html_entity_lookup.c
compiling xml_syntax_error.c
compiling xml_document.c
xml_document.c: In function ‘set_encoding’:
xml_document.c:159:12: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
xml_document.c: In function ‘canonicalize’:
xml_document.c:505:15: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
compiling xml_encoding_handler.c
compiling xml_namespace.c
xml_namespace.c: In function ‘prefix’:
xml_namespace.c:14:13: warning: variable ‘doc’ set but not used [-Wunused-but-set-variable]
xml_namespace.c: In function ‘href’:
xml_namespace.c:33:13: warning: variable ‘doc’ set but not used [-Wunused-but-set-variable]
compiling xml_entity_decl.c
compiling xml_attribute_decl.c
compiling xml_comment.c
compiling xml_dtd.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:189: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
有什么帮助吗?

请先尝试一下:

$  apt-get install libxml2-dev libxslt1-dev
此外,如果您正在使用rvm,请执行以下操作:

$ rvm requirements

Ubuntu12.10采用了Debian的强化包装,其中包括一组导致此编译错误的GCC默认标志。我们已经在Nokogiri 1.5.4和更高版本中解决了这个问题,因此您需要升级或找到自己的解决方法


请参阅。

无论是谁投票认为这是离题的,它都不是。这完全是关于堆栈溢出的主题。您是通过RVM安装ruby的吗?还有,为什么不使用1.5.6呢?因为我尝试绑定的gem给出了一个错误,即没有安装nokogiri 1.5.2。。。我还尝试在没有指定版本的情况下安装nokorigi,但没有成功…您可以更改Gemfile以指定较新的版本。然后不确定。我在rubygems.org的Ubuntu12.10中安装了1.5.6。唯一的区别是我使用的是ruby 1.9.3,而你的是ruby 1.9.1。如果可以,请尝试升级。或者试着找出nokogiri的确切版本,也就是抱怨它使用的宝石。这可能也有帮助谢谢,你救了我!