Gem gem install bcrypt-ruby 错误求助!

fengkuok · 2013年01月28日 · 最后由 fengkuok 回复于 2013年01月29日 · 4585 次阅读
Building native extensions.  This could take a while...
ERROR:  Error installing bcrypt-ruby:
    ERROR: Failed to build gem native extension.

        /usr/local/Cellar/ruby/1.9.3-p327/bin/ruby extconf.rb
creating Makefile

make
compiling bcrypt_ext.c
In file included from bcrypt_ext.c:1:
In file included from /usr/local/Cellar/ruby/1.9.3-p327/include/ruby-1.9.1/ruby.h:32:
/usr/local/Cellar/ruby/1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:48:11: fatal error: 'string.h' file not found
# include <string.h>
          ^
1 error generated.
make: *** [bcrypt_ext.o] Error 1


Gem files will remain installed in /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out

系统:OS X 10.8.2 ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.0.0] Rails 3.2.9

貌似你的系统上面没有 C Compiler 的头文件,你的 XCode 中安装了 Command Line Tools 了么?

有的呀,我是不是因为用 homebrew 装的 ruby 的一套东西所导致的啊

#2 楼 @fengkuok 那就不太容易判断了,你的 ruby 是通过 RVM 安装的么?

#2 楼 @fengkuok 不对,错误信息说找不到 string.h 你看一下 /usr/include/string.h 在不在?

#5 楼 @lgn21st 应该是指的 /usr/local/include下吧?/usr下没有include文件夹啊。 /usr/local/include下: FengtekiMacBook-Pro:include fengkuok$ ls gdbm.h ruby-1.9.1 sqlite3.h sqlite3ext.h yaml.h

正在更新 Xcode4.6,homebrew,ruby,gem...实在是太奇怪了!回想一下,也就是前几天用 brew 装了个 mongodb,不会是什么东西冲突了吧?

#4 楼 @lgn21st 我的 ruby 也是通过 homebrew 装的

#7 楼 @fengkuok 用 RVM 来装吧。

#8 楼 @lgn21st

FengtekiMacBook-Pro:~ fengkuok$ gem install bcrypt-ruby Building native extensions. This could take a while... Successfully installed bcrypt-ruby-3.0.1 1 gem installed Installing ri documentation for bcrypt-ruby-3.0.1... Installing RDoc documentation for bcrypt-ruby-3.0.1... FengtekiMacBook-Pro:~ fengkuok$

经过几个小时的更新,现在已经一切正常了!

github 上也找到了一些类似的 issues: https://github.com/flori/json/issues/127 https://github.com/carlhuda/bundler/issues/1809#issuecomment-5577993

我是更新了 Xcode,command line tools,homebrew,ruby,gem。。。 然后就一切正常了!

多谢@lgn21st

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