新手问题 ruby 1.8.7 如何安装 libxml-ruby 0.8.3?

newbie · 2013年12月16日 · 最后由 sevk 回复于 2013年12月17日 · 3164 次阅读

ruby 版本:1.8.7 OS: Ubuntu12.04

在 rails 项目下执行安装 gemfile 的命令

bundle install --path .bundle

得到下面结果


Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb 
extconf.rb:6: stack level too deep (SystemStackError)


Gem files will remain installed in /home/username/path/.bundle/ruby/1.9.1/gems/libxml-ruby-0.8.3 for inspection.
Results logged to /home/username/path/.bundle/ruby/1.9.1/gems/libxml-ruby-0.8.3/ext/libxml/gem_make.out

An error occurred while installing libxml-ruby (0.8.3), and Bundler cannot continue.
Make sure that `gem install libxml-ruby -v '0.8.3'` succeeds before bundling.

运行

sudo gem install libxml-ruby -v '0.8.3'

却提示:


Building native extensions.  This could take a while...
Successfully installed libxml-ruby-0.8.3
Installing ri documentation for libxml-ruby-0.8.3

No definition for input_callbacks_add_scheme

No definition for input_callbacks_remove_scheme

No definition for ruby_xml_node2_new_native

Enclosing class/module 'cXMLSaxParser' for module Callbacks not known

No definition for ruby_xml_html_parser_new_file

No definition for ruby_xml_html_parser_new_io

No definition for ruby_xml_html_parser_filename_get

No definition for ruby_xml_html_parser_filename_set

No definition for ruby_xml_html_parser_io_get

No definition for ruby_xml_html_parser_io_set

No definition for ruby_xml_parser_context_options_get

No definition for ruby_xml_parser_context_options_set
/usr/local/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/local/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Done installing documentation for libxml-ruby after 2 seconds
1 gem installed

但 Gemfile.lock 没法正常生成。

编辑 ~/.gemrc 加入下面两行

install: --no-ri --no-rdoc
update: --no-ri --no-rdoc

然后再 bundle 试试看?

另外 1.8.7 太老了...

#1 楼 @luikore 谢谢。是系统的 ruby 版本问题,已经解决。项目在用这个版本,没办法。

如果是处理 xml, 不需要安装 libxml 吧?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号