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
    gem install libv8 -v
    gem install --install-dir vendor/bundle therubyracer 

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', '~>'
  gem 'therubyracer', '~> 0.12.1'

Keep in Touch

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