7

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
gdavis
  • 2,556
  • 1
  • 20
  • 25
  • I've found a issue regarding this on github for therubyracer: https://github.com/cowboyd/therubyracer/issues/181 – gdavis Jul 26 '12 at 22:16

5 Answers5

7

Try to add

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

to your Gemfile. It helps for me.

sharipov_ru
  • 643
  • 4
  • 11
4

This is a quick guide on how to get rails running on 10.8: http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion

From the guide:

If you need to install any Ruby that’s older than 1.9.3, such as 1.9.2, 1.8.7 or REE, you’ll need to install GCC 4.2.

Joe
  • 2,987
  • 15
  • 24
  • 1
    Thanks for this! I've got GCC 4.2 installed, updated bundler, but still can't install libv8 using `gem install libv8 -v '3.3.10.4'`... any other ideas? – gdavis Jul 26 '12 at 21:35
1

Okay, after some digging and seeing I'm not the only one with the problem, I've found the solution. Ultimately, it was because the 'therubyracer' gem was referencing a version of libv8 that was't compiling on Mountain Lion. The fix was to update the gem to use a beta version of the gem which uses an more recent version of libv8. Here's a link to the issue on github: https://github.com/cowboyd/therubyracer/issues/181

I kept a list of crib notes of the entire process of getting rails back up and running, and here a short list of it for anyone it might help.

  • Uninstall and Reinstall Brew (it wouldn't update to 0.9 with brew update, so a manual reinstall was needed)
  • Install GCC Compiler that is no longer included as mentioned by @Joe - chown the /Library/Caches directory
  • Install MySQL
  • Install X11
  • Update Gemfile to use beta version of 'therubyracer' gem "therubyracer", "~> 0.11.0beta5"
  • Fix issues with Nokigiri and LibXML conflicts as covered here: WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8

bundle install and win!

Community
  • 1
  • 1
gdavis
  • 2,556
  • 1
  • 20
  • 25
0

I have a couple of suggestions. It might help to use rvm or rbenv rather than the system version of Ruby:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Another suggestion is to use the latest version of libv8 and the pre-release version of therubyracer which will compile against it.

Charles Lowell
  • 1,157
  • 8
  • 10
0

Although it is not updated to latest build env. (Xcode 4.4), following this answer (on question: Issue updating Ruby on Mac with Xcode 4.3.1) might help.

While Xcode version is different, basic setup is same.

I'm trying to build env with Xcode 4.4 had minor issue with specific gem(capybara-webkit) at this moment. Will update the answer.

Community
  • 1
  • 1
shigeya
  • 4,862
  • 3
  • 32
  • 33