Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't the bcrypt ruby gem install properly?

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.

like image 778
Philip7899 Avatar asked Sep 23 '13 20:09

Philip7899


3 Answers

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
like image 170
Envek Avatar answered Nov 03 '22 04:11

Envek


Try removing ,'3.0.1' or try like this gem "bcrypt", "~> 3.1.1"

Hope it helps.

If not, from console try running gem install bcrypt

like image 42
Yaro Avatar answered Nov 03 '22 04:11

Yaro


Actually a simple:

gem install bundler
gem install bcrypt-ruby

and then:

bundle update bcrypt-ruby
or bundle update bcrypt

Would've done the trick.

It's much the same way that you would upgrade rails. If you wanted to make sure you could also specify the latest bcrypt-ruby in your Gemfile. I just did this ten minutes ago so I know it works as of the date of this post... I was using ruby 1.9.3 p484

like image 27
mystic cola Avatar answered Nov 03 '22 06:11

mystic cola