安装带扩展名的gem总是会失败

时间:2013-07-19 01:21:14

标签: ruby rubygems gem

我刚安装了一台Ubuntu 13.04服务器,并安装了RVM 1.21.11,Ruby 1.9.3-p448和Rubygems 2.0.5。

许多gems,例如 mongo awesome_print aws-s3 json ,已成功安装。

但是,编译扩展的gem失败了。我试图安装 nokogiri mongo_ext bson_ext 。它们都以同样的方式失败,如下所示。

知道如何解决这个问题吗?

[nick@mongo01 ~] gem install mongo_ext -u -V --backtrace
HEAD http://rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
HEAD http://production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
Installing gem mongo_ext-0.19.3
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/Rakefile
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/mongo-extensions.gemspec
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/extconf.rb
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/buffer.c
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/cbson.c
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/encoding_helpers.c
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/buffer.h
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/encoding_helpers.h
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/version.h
Building native extensions.  This could take a while...
/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for asprintf()... yes
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... yes
creating Makefile
make "DESTDIR="
compiling encoding_helpers.c
compiling buffer.c
compiling cbson.c
cbson.c: In function 'write_utf8':
cbson.c:80:36: warning: pointer targets in passing argument 1 of 'check_string' differ in signedness [-Wpointer-sign]
In file included from cbson.c:46:0:
encoding_helpers.h:26:10: note: expected 'const unsigned char *' but argument is of type 'char *'
cbson.c: In function 'objectid_generate':
cbson.c:858:5: warning: implicit declaration of function 'htonl' [-Wimplicit-function-declaration]
cbson.c:867:5: warning: implicit declaration of function 'htons' [-Wimplicit-function-declaration]
cbson.c: In function 'write_element':
cbson.c:264:17: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]
linking shared-object mongo_ext/cbson.so
make "DESTDIR=" install
/usr/bin/install -c -m 0755 cbson.so /usr/local/rvm/gems/ruby-1.9.3-p448/gems/mongo_ext-0.19.3/ext/cbson/.gem.20130718-9545-1ue92ws/mongo_ext
installing default cbson libraries
ERROR:  While executing gem ... (NoMethodError)
    undefined method `join' for nil:NilClass
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:685:in `rescue in block in build_extensions'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:675:in `block in build_extensions'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:653:in `each'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:653:in `build_extensions'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:218:in `install'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:371:in `block in install'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:331:in `each'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:331:in `each_with_index'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:331:in `install'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:166:in `block in execute'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:158:in `each'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:158:in `execute'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:305:in `invoke_with_build_args'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:170:in `process_args'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:130:in `run'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:60:in `run'
        /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/gem:21:in `<main>'
[nick@mongo01 ~]
[nick@mongo01 ~] gem -v
2.0.5
[nick@mongo01 ~] ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
[nick@mongo01 ~] rvm -v

rvm 1.21.11 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

2 个答案:

答案 0 :(得分:0)

这通常是因为需要在您的系统上编译本机扩展,并且您没有安装正确的开发工具。你做过这个吗?

 yum groupinstall 'Development Tools'

这些工具中的一个可能是错误的版本,或以其他方式出现过?

答案 1 :(得分:0)

这是由RubyGems中的错误引起的。它已在8d1751c6中修复。

在RubyGems v2.0.6发布之前,解决方法是手动应用8d1751c6