1

OS: Mac OS X 10.8.2 XCode: Latest with command line tools installed (version 4.6) Rails: version 3.2.3

I was trying to generate the routes for a project I am working on (been doing that on regular basis), when I got an error message, with a recommendation that I do bundle install and bundle exec. I did, and this time around, the process broke off while compiling the JSON Gem (version 1.7.7).

Doing some research on StackOverflow, the recommendation was to update the XCode's command line tools, and I did, but that did not solve the problem.

I tried installing the JSON version 1.7.7 separately, and it failed, telling me to look for the error log in:

~/.rvm/gems/ruby-1.9.3-p125/gems/json-1.7.7/ext/json/ext/generator/gem_make.out 

Which reads:

/Users/mine/.rvm/rubies/ruby-1.9.3-p125/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 

I looked for /usr/bin/gcc-4.2, and indeed, it's not there. But, when I do:

ls -l /usr/bin/gcc 

Here's what I get:

lrwxr-xr-x 1 root wheel 12 Feb 14 15:49 /usr/bin/gcc -> llvm-gcc-4.2 

How do I fix this problem?

1
  • Have you tried symlinking /usr/bin/gcc-4.2 to the same binary? cd /usr/bin && sudo ln -s llvm-gcc-4.2 gcc-4.2 Commented Feb 15, 2013 at 0:24

2 Answers 2

2

I think the problem is that when you install the Xcode command line tools, gcc is sym-linked to llvm, and llvm can't always compile Ruby and gems correctly.

If you install autoconf, automake, and gcc directly (or through something like Homebrew), you should be able to fix the compiler errors.

Sign up to request clarification or add additional context in comments.

3 Comments

Caveat: make sure that you do sudo, else "brew install gcc" will ail. This worked for bundle:install. I am now however unable to do "rake routes", I get the following error message: You have already activated rake 10.0.3, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this.
Did bundle exec fix this? You could also try changing the version of rake specified by your Gemfile.
I had to uninstall rake, and add gem 'rake' to my gemfile, then re-run bundle:install. That fixed the problem.
0

The problem is that the gcc you used to compile your installed version of ruby got removed as part of the xcode upgrades. Using RVM rebuild your ruby (you might want to upgrade to the latest version as well). Once you do that, you should have no problem building gems with native extensions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.