我已经决定开始尝试使用Ruby来摆脱我的小Java框,并且希望从一些个人项目开始,以一些书面地址和地理编码为基础。如何在OS X 10.6.8中设置Ruby?
作为开始,我得到了Koans,并开始在命令行中使用它们,只是使用安装在OS X中的Ruby(ruby -version返回1.8.7)。到现在为止还挺好。然后我用gem install geocoder
,很好地工作。但也有一些它的对象的工作,它需要JSON,所以到时gem install json
...
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/sharakan/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Users/sharakan/.gem/ruby/1.8/gems/json-1.7.3 for inspection.
Results logged to /Users/sharakan/.gem/ruby/1.8/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
的gem_make.out文件只是具有相同的mkmf.rb错误。
经过一番搜索之后,我发现有类似声音问题的人通过安装XCode发现了解决方案。我很久没有见过我的XCode DVD了,现在Apple提供的版本需要10.7。
我还发现一些信息,使RVM听起来像它可能会解决问题。但遗憾的是,编译问题也失败了:
[2012-06-11 20:50:00] ./configure --prefix=/Users/sharakan/.rvm/rubies/ruby-1.9.3-p194 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/sharakan/.rvm/usr
configure: WARNING: unrecognized options: --with-libyaml
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/sharakan/.rvm/src/ruby-1.9.3-p194':
configure: error: C compiler cannot create executables
See `config.log' for more details
那么下一步该去哪里?我真的需要购买Lion来让Ruby在我的机器上工作吗?
检查自制和rbenv。我想'brew doctor'应该让你安装rbenv –