Why do I get a bcrypt-ruby gem install error?

led picture led · May 25, 2011 · Viewed 19.3k times · Source

Getting an error when trying to install the gem devise, the installation is stopping on the gem bcrypt-ruby:

$ gem install bcrypt-ruby
Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.

I'm running OSX 10.6.7 with Ruby under RVM. I reinstalled the lastest version of xcode & reinstalled Ruby 64bit, Rails and all the gems.

Answer

Curley picture Curley · Mar 6, 2012

I had the same problem installing under OSX 10.7.3. When installing the gem, my error message was:

Building native extensions.  This could take a while...
ERROR:  Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.

creating Makefile

make
compiling bcrypt_ext.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [bcrypt_ext.o] Error 1

Looks like the gem is looking for gcc-4.2 but I only had a file called gcc. Now since I had just installed the latest Xcode (4.3), I knew that my C compiler was compliant but the gem had gcc-4.2 hardcoded into it. So my solution was:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

The linking worked like a charm.