Steven L
Steven L

Reputation: 131

Error: extconf failed, exit code 1 [Ruby on Rails]

got an error while trying to install devise gem. Added gem "devise", "~> 3.2.2" to my Gemlist and went into terminal to do the following:

Steven-Lims-MacBook-Pro:Pinteresting stevenlim$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.2)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
checking for ruby/util.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby
/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:565:in `try_cpp'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
    from extconf.rb:14:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bcrypt-ruby-3.1.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-10/2.0.0/bcrypt-ruby-3.1.2/gem_make.out
An error occurred while installing bcrypt-ruby (3.1.2), and Bundler cannot
continue.
Make sure that `gem install bcrypt-ruby -v '3.1.2'` succeeds before bundling.

Am new to programming and Ruby on Rails so kindly assist. Thanks!

Upvotes: 3

Views: 15407

Answers (2)

ea0723
ea0723

Reputation: 806

Ran into this issue after updating OS X Mavericks to 10.9.5 which also updates Xcode (Version 6.0.1 (6A317)).

    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/e/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb 
    creating Makefile
    Compiling v8 for x64
    Using python 2.7.5
    Unable to find a compiler officially supported by v8.
    It is recommended to use GCC v4.4 or higher
    Using compiler: /usr/bin/c++ (c++ version ) 

    extconf failed, exit code 1

    Gem files will remain installed in /Users/e/.rvm/gems/ruby-2.1.1/gems/libv8-3.16.14.7 for inspection.
    Results logged to /Users/e/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-12/2.1.0-static/libv8-3.16.14.7/gem_make.out

    An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue.
    Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

To resolve: Must accept and finalise install of Xcode in order for bundle update to complete.

After finalising install of Xcode, bundle update completed without issue.

Upvotes: 0

Steven L
Steven L

Reputation: 131

managed to solve this. I had upgraded to OS Mavericks recently and problem came up.

Have tried gem install bcrypt-ruby -v '3.1.2' in terminal but encountered same problem.

Thereafter, went to install Xcode on App Store as running Xcode-select --install in terminal failed as well (program can't be found).

Thus I chanced upon this thread and followed advice to run sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2 in terminal.

Thread: gem install pg doesn't work on OSX Lion

Thereafter I ran gem install bcrypt-ruby -v '3.1.2' and bundle install in terminal and all good for now. Hope this works. Actually I don't know what I am doing but hopefully it works. Can someone enlighten me what I am actually doing?

Upvotes: 3

Related Questions