I’ve decided to start experimenting with Ruby to get out of my little Java box, and want to start with a little personal project taking some written addresses and geocodes them.
As a start, I got the Koans and started messing about with them from the command line, just using Ruby as installed in OS X (ruby -version returns 1.8.7). So far, so good. Then I used gem install geocoder, which worked nicely. But to work with some of it’s objects, it needs json, so on to gem install json when…
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
The gem_make.out file just has the same mkmf.rb error.
After doing a bit of searching, I found that people with similar sounding problems found resolution by installing XCode. I haven’t seen my XCode DVD in a long time, and the version available from Apple now requires 10.7.
I also found some information that made RVM sound like it might solve the problem. But sadly that too failed with compilation problems:
[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
So where to go next? Do I really need to purchase Lion to get Ruby working on my machine?
If your issue that you don’t have xcode installed, you really just need make, gcc, etc installed.
The easiest way to do this to just use OS X GCC Installer
Installing that should get you on your way.