Why won't the bcrypt ruby gem install properly?

Philip7899 picture Philip7899 · Sep 23, 2013 · Viewed 18.2k times · Source

I am trying to encorporate bcrypt-ruby, v. 3.0.1. I enter the gem in my gem file as follows:

gem 'bcrypt-ruby', '3.0.1'

And I then go to the terminal and run:

bundle install

I get the following response:

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

    /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb 
creating Makefile

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


Gem files will remain installed in /Users/philip7899/.bundler/tmp/2186/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/philip7899/.bundler/tmp/2186/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.

I am extremely new to both Ruby and Rails and have no idea how to fix this. I have seen other stackoverflow pages with similar questions but none have been able to help me. I recently upgraded to Mountain Lion and was told that could be an issue. I was told to use RVM to uninstall and then reinstall Ruby. I tried that and it did not work.

Please help. Thank you.

Answer

Envek picture Envek · Dec 28, 2015

In recent versions bcrypt-ruby seems to use the GMP library.

So, on Linux something like this should help (command for Ubuntu 14.04):

sudo aptitude install libgmp-dev