1

I'm trying to update gem file from a freshly created Rails app. Each time I get the following:

Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.0)
Using bundler (1.3.5)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.2)
Using jquery-rails (3.0.4)
Installing json (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/adrianleeelder/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
make: gcc-4.2: No such file or directory
make: *** [generator.o] Error 1


Gem files will remain installed in /Users/adrianleeelder/.rvm/gems/ruby-2.0.0-p0/gems/json-1.8.1 for inspection.
Results logged to /Users/adrianleeelder/.rvm/gems/ruby-2.0.0-p0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.

I updated to OS X Mavericks a while back and ever since I have had this problem. A lot of users are suggesting to run the command: xcode-select --install.

Adrian Elder
  • 1,993
  • 3
  • 19
  • 38

2 Answers2

8

I fixed the error by doing the following:

1) Run the command which gcc

2) Then based on the output adjust this command and run it: ln -s /usr/bin/gcc /usr/bin/gcc-4.2 (May have to prepend sudo if permission is denied)

The bundle command should compile the gems correctly now.

Installing Xcode will also work. I had already installed Xcode, but for some reason when I tried to launch it recently it prompted an install. Using Alfred (the quick launch application) I typed Xcode and launched the installer.

Adrian Elder
  • 1,993
  • 3
  • 19
  • 38
0

I fixed the error through homebrew using the following:

brew tap homebrew/versions && brew install apple-gcc42

brew link --force apple-gcc42

ln -nsf $(which gcc-4.2) /usr/bin/gcc-4.2

You may have to 'sudo' for the last command if you get permission issues.