3
votes

I'm getting the following error on a new Rails installation. I run bundle install and after installing a bunch of gems, I get an error upon trying to install bcrypt-ruby. I'm using a brand new Mac with OS X 10.8.2, latest Ruby (v1.9.3-p194), new Rails (v3.2.8) and standard Gemfile.

Installing activerecord (3.2.8)

Installing activeresource (3.2.8)

Installing bcrypt-ruby (3.0.1) with native extensions

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

    /Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb  creating Makefile

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

Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p194@mygemset/gems/bcrypt-ruby-3.0.1 for inspection. Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p194@mygemset/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.

UPDATE: Forgot to mention, not only in this a brand new Mac with Mac OS X 10.8.2, but also brand new Xcode installed yesterday and with command line tools. I then installed RVM and brew.

4

4 Answers

7
votes

Seems odd on a brand new Mac, with new OS and new RVM installation that I would need to do this.. but what worked was simply linking gcc-4.2 to gcc:

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

For me, the following worked

gem uni bcrypt-ruby
gem i bcrypt-ruby --platform=ruby
0
votes

Have you upgraded to Lion since you installed Ruby 1.9.3? If so it is probably linked to the wrong gcc.

Try uninstalling and reinstalling 1.9.3, I would suggest using rvm

rvm uninstall 1.9.3
rvm install 1.9.3

If that does not work you might have to implode rvm

rvm implode
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bash_profile
rvm install 1.9.3
0
votes

According to this article, it seems to be caused by an update to xcode tools on mac, to fix this you need to add a flag to ignore that error like it used to do before.

For example in my case this worked:

gem install bcrypt-ruby:3.0.1 -- --build-flags --with-cflags="-Wno-error=implicit-function-declaration"