Rails & Yosemite: Resolving libv8 and therubyracer Installation Problems
Tags: development, yosemite • Categories: Web Development
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
Nice! I ran into that, but resolved it in an uglier fashion.
What v8 are you using? brew install v8?
I’m not using brew’s v8, just the stock v8 that comes with yosemite.
Thanks a lot! This fixed my problem, wasted 6 hours to find a solution on Stackoverflow and these 4 lines helped.
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
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