33

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.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
led
  • 361
  • 1
  • 4
  • 9

9 Answers9

30

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.

Curley
  • 1,621
  • 15
  • 13
6

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.

Ryan Clark
  • 764
  • 1
  • 8
  • 29
5

It requires to install ruby-dev before installing bcrypt-ruby. If you are using Ubuntu, run

sudo apt-get install ruby1.9.1-dev

or

sudo apt-get install ruby1.8-dev

based on RUby version.

Thomas Tran
  • 467
  • 4
  • 8
2

You only need use rvm (ruby version manager)

rvm uninstall 1.9.3

and then

rvm install 1.9.3

looks this error is on build of rvm 1.9.3, but uninstall and reinstalling fix the problem with bcrypt-ruby 3.0.1

2

I'm using RVM & I kept having this issue whenever installing gems with native extensions (bcrypt-ruby, bson-ext, json, eventmachine, nokogiri, linecache19, etc.)

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

Only way I could finally get things working was to uninstall then re-install ruby.

rvm remove 1.9.2

rvm install 1.9.2

Thanks to tip from @doublebee here: https://github.com/flori/json/issues/78#issuecomment-1499920

brandonjp
  • 3,018
  • 2
  • 28
  • 27
1

Well, it works with Ruby 1.9.2 under RVM on MacOS 10.6.7:

$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]

$ gem install bcrypt-ruby
Fetching: bcrypt-ruby-2.1.4.gem (100%)
Building native extensions.  This could take a while...
Successfully installed bcrypt-ruby-2.1.4
1 gem installed
Installing ri documentation for bcrypt-ruby-2.1.4...
Installing RDoc documentation for bcrypt-ruby-2.1.4...

Try rvm notes and see if it says you need to install anything.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
1

If you are using version 1.8 the required packages for bcrypt are in the dev bundle. Try using

$sudo apt-get install ruby1.8-dev

then

$gem install bcrypt-ruby 
Christian Specht
  • 35,843
  • 15
  • 128
  • 182
ivt
  • 27
  • 2
0

This fix work for me on ubuntu on osx use homebrew, macports whatever:

sudo apt-get install ruby1.9.1-dev
fillky
  • 591
  • 2
  • 6
  • 18
0

I think you need to reinstall bundler gem.

gem install bundler and then bundle install

Zakaria
  • 983
  • 15
  • 24