With Ruby On Rails 4.2.5.1 I can gem install therubyracer but bundle fails on OS X 10.11.1

1.3k Views Asked by At

Using rbenv for a Ruby 2.3.0 environment on OS X 10.11.1 I am unable to get therubyracer Gem to install when using 'bundle'.

This is successful:

> gem install therubyracer
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.12.2
Parsing documentation for therubyracer-0.12.2
Done installing documentation for therubyracer after 0 seconds
1 gem installed

In my Gemfile:

gem 'therubyracer', '0.12.2', platforms: :ruby

This fails:

> bundle
Installing therubyracer 0.12.2 (was 0.12.1) with native extensions

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

current directory: /Users/jsidlosky/code/sentons/websocket-rails-demo/.bundle/gems/therubyracer-0.12.2/ext/v8
/Users/jsidlosky/.rbenv/versions/2.3.0/bin/ruby -r     ./siteconf20160215-9105-1s1s0pv.rb extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... no
*** 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.
....
To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Users/jsidlosky/code/sentons/websocket-rails-demo/.bundle/extensions/x86_64-darwin-15/2.3.0-static/therubyracer-0.12.2/mkmf.log

The mkmf.log file's error is:

conftest.c:3:10: fatal error: 'v8.h' file not found

Some things I've tried:

From: How to install therubyracer gem on 10.10 Yosemite?

git clone https://github.com/cowboyd/libv8.git
cd libv8
bundle install
bundle exec rake clean build binary
gem install pkg/libv8-3.16.14.13.gem

From: Bundle install tries to use cache file

Adding to ~/.bundle/config

BUNDLE_PATH: .bundle
BUNDLE_DISABLE_SHARED_GEMS: "1"

I also tried this:

bundle config build.libv8 --with-system-v8

I've now spent well over 5 hours trying other random ideas from various StackOverflow questions and other sites. So far, nothing gets me a working therubyracer inside "bundle" even though "gem install therubyracer" works just perfectly.

I will be very grateful for any pointers or solutions.

1

There are 1 best solutions below

0
On

It appears from the comment from: github.com/cowboyd/therubyracer/issues/359

"I wasn't able to get any of the above solutions to work (or rather, everything I could get to work would have required the rest of my team to rebundle). After switching from rbenv to RVM, however, bundle install ran without a hitch."

I tried switching from rbenv to RVM and it worked perfectly. I can now 'bundle' and therubyracer gem installs perfectly.