我已经运行了命令: gem install bcrypt'3.1.7'。
不幸的是,gem无法安装。相反,我得到以下输出:
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时遇到了问题,但他们使用的建议都没有解决这个问题。
我该如何解决这个问题?
答案 0 :(得分:1)
仔细查看输出后,我注意到错误列表已配对。看起来它们是单独的错误,但是它们实际上是基于输出中提到的冲突成对出现的。每对指的是两个不同的目录,每个目录对应不同的ruby安装。
删除系统安装版本(即通过' yum')并保留rvm安装版本,然后运行gem install命令后,问题就解决了。