我决定开始尝试 Ruby 以摆脱我的 Java 小盒子,并想从一个小的个人项目开始,获取一些书面地址并对其进行地理编码。
作为开始,我得到了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 在我的机器上运行吗?