Skip to content

Rails & Yosemite: Resolving libv8 and therubyracer Installation Problems

Tags: development, yosemite • Categories: Web Development

Table of Contents

As a developer, upgrading to a new OS is always a task, especially when it comes to rails dependencies (surprisingly, Cocoa projects didn’t have as much of an issue with Yosemite).

I always wipe my machine and start fresh. This introduces a new class of problems, some of which I was able to mitigate this time around with mackup (a preference backup and restoration tool) and some upgrades to my dotfiles.

I customize bundler to work in parallel, store all gems for a given project in the vendor/ directory for that project, and to not use shared gems at all.

LibV8 Compilation Issues

I ran into this error when bundler tried to install libv8 on Yosemite:

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

I found a similar problem on StackOverflow, but my situation was a bit different because of my use of disable-shared-gems

if ! bundle show therubyracer; then
    bundle config build.libv8 --with-system-v8
    gem install --install-dir vendor/bundle libv8 -v 3.16.14.7
    gem install libv8 -v 3.16.14.7
    gem install --install-dir vendor/bundle therubyracer 
fi

Update: It’s also important to lock down therubyracer and libv8 gems in your Gemfile:

group :production do
  gem 'unicorn', '~> 4.8.3'
  gem 'libv8', '~> 3.16.14.7'
  gem 'therubyracer', '~> 0.12.1'
end

5 responses to “Rails & Yosemite: Resolving libv8 and therubyracer Installation Problems

  1. Thanks Mike! Same comment as Stefan! I guess it was the combination of the versions for libv8 and therubyracer that did it. I have installed v8 with brew and I decided to install the gems without bundler as this:

    gem install libv8 -v ‘3.16.14.7’ — –with-system-v8
    gem install therubyracer -v ‘0.12.1’

    Then I updated the versions in my Gemfile (the same way you have in your post) and did bundle install

  2. A better solution to this problem is the following bundler config:

    bundle config build.pg — –with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config

    Note you’ll need to change the pg-config path depending on your Postgres.app version

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep in Touch

Subscribe to my email list to keep in touch. I’ll send you new blog posts and other thoughts.