Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 286
led Avatar asked May 25 '11 03:05

led


People also ask

What is GEM Bcrypt?

bcrypt() is a sophisticated and secure hash algorithm designed by The OpenBSD project for hashing passwords. The bcrypt Ruby gem provides a simple wrapper for safely handling passwords.

Does Ruby install gem?

Ruby installs the dependency rbtree and builds its extension, installs the drip gem, then builds documentation for the installed gems. You can disable documentation generation using the --no-document argument when installing gems.

What is gem install?

gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):


2 Answers

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.

like image 152
Curley Avatar answered Sep 29 '22 13:09

Curley


Looks like there might be some info missing here - for me, this was due to a brew install of gcc. gcc was in /usr/bin, but not gcc-4.2. So I just did the following:

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

which creates a link, gcc-4.2, which the gem is looking for that goes back to gcc.

Hope that helps.

like image 21
Ryan Clark Avatar answered Sep 29 '22 14:09

Ryan Clark