2014-08-30 153 views
1

我運行命令: gem install bcrypt'3.1.7'。安裝bcrypt-ruby時出錯

不幸的是,寶石無法安裝。相反,我得到以下輸出:

Fetching: bcrypt-3.1.7.gem (100%) 
Building native extensions. This could take a while... 
ERROR: Error installing bcrypt-ruby: 
     ERROR: Failed to build gem native extension. 

    /usr/local/rvm/rubies/ruby-1.8.7-head/bin/ruby extconf.rb 
checking for ruby/util.h... yes 
creating Makefile 

make 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_RUBY_UTIL_H -fPIC -O2 -fno-tree 
-dce -fno-optimize-sibling-calls -fPIC -c crypt.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_RUBY_UTIL_H -fPIC -O2 -fno-tree 
-dce -fno-optimize-sibling-calls -fPIC -c crypt_gensalt.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_RUBY_UTIL_H -fPIC -O2 -fno-tree 
-dce -fno-optimize-sibling-calls -fPIC -c crypt_blowfish.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_RUBY_UTIL_H -fPIC -O2 -fno-tree 
-dce -fno-optimize-sibling-calls -fPIC -c bcrypt_ext.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_RUBY_UTIL_H -fPIC -O2 -fno-tree 
-dce -fno-optimize-sibling-calls -fPIC -c wrapper.c 
In file included from /usr/include/ruby/util.h:22:0, 
       from wrapper.c:28: 
/usr/include/ruby/defines.h:71:7: error: conflicting types for ‘ruby_xmalloc’ 
void *xmalloc(size_t); 
    ^
In file included from /usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/ruby.h:37:0, 
       from wrapper.c:26: 
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/defines.h:49:7: note: previous declaration of ‘ruby_xmalloc’ was here 
void *xmalloc _((long)); 
    ^
In file included from /usr/include/ruby/util.h:22:0, 
       from wrapper.c:28: 
/usr/include/ruby/defines.h:73:7: error: conflicting types for ‘ruby_xcalloc’ 
void *xcalloc(size_t,size_t); 
    ^
In file included from /usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/ruby.h:37:0, 
       from wrapper.c:26: 
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/defines.h:50:7: note: previous declaration of ‘ruby_xcalloc’ was here 
void *xcalloc _((long,long)); 
    ^
In file included from /usr/include/ruby/util.h:22:0, 
       from wrapper.c:28: 
/usr/include/ruby/defines.h:74:7: error: conflicting types for ‘ruby_xrealloc’ 
void *xrealloc(void*,size_t); 
    ^
In file included from /usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/ruby.h:37:0, 
       from wrapper.c:26: 
/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux/defines.h:51:7: note: previous declaration of ‘ruby_xrealloc’ was here 
void *xrealloc _((void*,long)); 
    ^
make: *** [wrapper.o] Error 1 


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.8.7-head/gems/bcrypt-3.1.7 for inspection. 
Results logged to /usr/local/rvm/gems/ruby-1.8.7-head/gems/bcrypt-3.1.7/ext/mri/gem_make.out 
ERROR: Could not find a valid gem '3.1.5' (>= 0) in any repository 

這基本上是一個相當虛假的'make'未完成的問題傾瀉出來。我發現很多人在安裝bcrypt時遇到了問題,但他們使用的任何建議都無法解決這個特殊問題。

我該如何解決這個問題?

回答

1

仔細觀察輸出後,我發現錯誤列表已配對。它看起來像是單獨的錯誤,但它們實際上是基於輸出中提到的衝突而成對的。每一對都指向兩個不同的目錄,每個目錄對應不同的紅寶石安裝。

刪除系統安裝版本(即通過'yum')並保留rvm安裝版本,然後運行gem install命令後,問題就解決了。