ruby-on-railsrubyrubygemsbcrypt-ruby

Installing bcrypt gem failed


gem install bcrypt
Building native extensions.  This could take a while...
ERROR:  Error installing bcrypt:
    ERROR: Failed to build gem native extension.

    /Users/mohit/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile

make  clean

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

make failed, exit code 2

Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p547/gems/bcrypt-3.1.9 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/bcrypt-3.1.9/gem_make.out

Edit with additional info from the OP:

$ xcode-select --install 
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

$ brew doctor
Warning: You have uncommitted modifications to Homebrew 
If this a surprise to you, then you should stash these modifications. 
Stashing returns Homebrew to a pristine state but can be 
undone should you later need to do so for some reason. 
cd /usr/local/Library && git stash && git clean -d -f

$ brew info gcc 
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': 
cannot load such file -- global (LoadError) from 
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:
in require' from /usr/local/Library/brew.rb:16:in `<main>'

$ gcc -v 
Configured with:
  --prefix=/Applications/Xcode.app/Contents/Developer/usr
  --with-gxx-include-dir=/usr/include/c++/4.2.1 
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) 
Target: x86_64-apple-darwin14.0.0 Thread model: posix

$ ls -ladg /usr/local/opt/gcc* 
No such file or directory 

Solution

  • OSX help

    1. Try installing XCode, which tends to be a huge download:

      $ xcode-select --install
      
    2. If the result is anything like this message below, that's ok for now.

      command line tools are already installed, 
      use "Software Update" to install update
      
    3. Update OSX to ensure it's ok and current:

      Apple Menu -> About This Mac -> Software Update
      
    4. Verify you have a current system, 10.10 as of this writing:

      $ sw_vers
      ProductName: Mac OS X
      ProductVersion: 10.10
      BuildVersion: 14A389
      

    Brew help

    1. If you use the homebrew package manager, what version? (Please post output)

      $ brew --version
      
    2. Verify brew is healthy:

      $ brew doctor
      
    3. If the doctor finds any errors, fix these. For example, doctor may say to do this, so do it:

      cd /usr/local/Library && git stash && git clean -d -f – 
      
    4. When doctor says everything is fine, then bring brew current:

      $ brew update
      $ brew upgrade
      
    5. Is homebrew adding GCC? (Please post output)

      $ brew info gcc 
      

    GCC help

    1. Is GCC available?

      $ command -v gcc
      /usr/bin/gcc
      
    2. See if your CC compiler variable is blank or set. (Please post the output)

      $ echo $CC
      
    3. What GCC version are you running? (Please post the output)

      $ gcc -v
      ...
      Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn)
      ...
      
    4. Do you have any GCC installed where Ruby is looking? (Please post the output)

      $ ls -ladg /usr/local/opt/gcc*
      lrwxr-xr-x 1 admin 21 Dec 18 16:41 /usr/local/opt/gcc -> ../Cellar/gcc/4.9.2_1
      

    Root gem help

    1. Does the gem install if you're root?

      $ sudo su -
      $ gem install bcrypt