After Xcode 4.4 and OSX 10.8 Installation - 'Failed to build gem native extension' when installing libv8

ruby, ruby-on-rails

Solution

Try to add

gem 'therubyracer', '0.11.0beta5'
gem 'libv8', '~> 3.11.8'

to your Gemfile. It helps for me.

Problem

I've recently upgraded OSX to Mountain Lion (10.8) and Xcode (4.4) and ran into issues when trying to get my rails environment working. I started with running `bundle install` and ran into an error when installing the `libv8` library. Below is a paste of the full error. I've search around and looked for similar issues, but what I found on stackoverflow so far has not applied to my problem. Here are the few things I've tried so far with no avail: - install Xcode Command Line Tools - install MySQL - install X11 - install different versions of libv8 via the gemfile Now I'm at a point where the problem seems to be exceeding my ruby skills. If anyone has some ideas on what I can try or are experiencing a similar issue, I'd love your help. Thanks! Here's what my gemfile looks like: ``` source 'https://rubygems.org' gem 'rails', '3.2.6' gem 'bundler' gem 'rake' gem 'sqlite3' gem 'haml' gem 'nokogiri' gem 'whenever' gem 'mysql' gem 'mysql2' gem 'jquery-rails' gem 'capistrano' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end ``` And here's the error log when trying to install gems: ``` sudo bundle install Password: Fetching source index for https://rubygems.org/ Using rake (0.9.2.2) Using i18n (0.6.0) Using multi_json (1.3.6) Using activesupport (3.2.6) Using builder (3.0.0) Using activemodel (3.2.6) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.1) Using rack-cache (1.2) Using rack-test (0.6.1) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.1.3) Using actionpack (3.2.6) Using mime-types (1.19) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.4.4) Using actionmailer (3.2.6) Using arel (3.0.2) Using tzinfo (0.3.33) Using activerecord (3.2.6) Using activeresource (3.2.6) Using bundler (1.0.15) Using highline (1.6.13) Using net-ssh (2.5.2) Using net-scp (1.0.4) Using net-sftp (2.0.5) Using net-ssh-gateway (1.1.0) Using capistrano (2.12.0) Using chronic (0.6.7) Using coffee-script-source (1.3.3) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.2) Using json (1.7.3) Using rdoc (3.12) Using thor (0.15.4) Using railties (3.2.6) Using coffee-rails (3.2.2) Using haml (3.1.6) Using jquery-rails (2.0.2) Installing libv8 (3.3.10.4) with native extensions /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/installer.rb:482:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb *** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb:13: uninitialized constant Gem (NameError) Checking for Python... Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/libv8-3.3.10.4 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/libv8-3.3.10.4/ext/libv8/gem_make.out from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/installer.rb:445:in `each' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/installer.rb:445:in `build_extensions' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/installer.rb:197:in `install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:101:in `install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:78:in `preserve_paths' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:91:in `install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:58:in `run' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:93:in `with_build_args' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:57:in `run' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:49:in `run' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:8:in `install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/cli.rb:222:in `install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `send' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `run' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor.rb:246:in `dispatch' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/base.rb:389:in `start' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/bin/bundle:13 from /usr/bin/bundle:19:in `load' from /usr/bin/bundle:19 ```

Original source

Related problems