"Failed to create your own gem extension" when installing Rails

I am new to Terminal, so please carry me. The successful installation of the following has been completed (in this order):

  • xcode 4.5
  • RVM 1.16
  • GCC 4.2.1
  • Ruby 1.9.3

When I try to install Rails ("gem install rails"), the installation starts, but then fails with the error: "Failed to create your own gem extension." I don’t know what this refers to. Ideas? Anything else I need to install in advance?
The first time I tried to install Rails, I accidentally ran it using sudo. Will it affect anything?

Edit: and output is -

Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/staffanestberg/.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/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection. Results logged to /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out 


Edit: Allowed using the iouri clause. Add export CC=gcc to your .bash profile, then create a symlink for the correct compiler,

 sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 
+7
source share
2 answers

Make sure you have the command line tools installed for Xcode first, Xcode> Preferences> Downloads> Components. Then add this line to your .bash_profile file in your home ~/.bash_profile folder:

 export CC=gcc 

Double check that you have gcc (possibly a symbolic link) in your / usr / bin (most likely), and that it points to a valid gcc compiler, ex: gcc -> llvm-gcc-4.2

You may need to reboot the terminal for this change to affect.

+8
source

Ruby is not completely ready to compile LLVM, including clang, there is at least one known isue with Fibers, but other problems may appear depending on the version of LLVM.

The correct way to fix this in order to get gcc-4.2 , there are many ways to do this, and the best ones are described in the requirements:

 rvm get stable rvm reload rvm requirements run rvm reinstall 1.9.3 
+5
source

All Articles