I am trying to build my first ruby on rails app using the following guide (http://ruby.railstutorial.org/chapters/a-demo-app#code-demo_gemfile_sqlite_version_redux) and have run into a few obstacles. The first, receiving errors when upgrading to the latest rails version 3.2.8.
bash-3.2$ gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection.
Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
Even when trying to install from rails app:
$ gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection.
Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
When trying to Bundle Install:
$ bundle install
Could not locate Gemfile
Background details:
Mac OS X Version 10.8.2
Ruby 1.9.3
Rails 2.3.4
I'm wondering if there is a direct one-liner or gem that is missing?
edit: sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Then run bundle update rails
Rails 3.2.8 should run now. Thanks to @peterwongpp for the post (http://peterwongpp.com/posts/missing-gcc-4-2-on-mountain-lion).
Best Answer
What it's looking for and not finding is a program called GCC, which is a C compiler. A fair number of Ruby libraries have some parts written in C, either for speed or to interface with existing C libraries.
I believe that installing XCode may clear this up: it's kind of a pain but you'd have to do it at some point anyway.