3

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.

Community
  • 1
  • 1
jsidlosky
  • 407
  • 1
  • 5
  • 17
  • You don't need therubyracer if you have nodejs installed on the system. – Linus Oleander Feb 15 '16 at 21:20
  • I am trying to get some existing rails projects compiling, and i'd rather not change how they work to get them to work. Are you saying that simply installing nodejs (e.g. brew install nodejs?) would resolve this bundle issue? – jsidlosky Feb 15 '16 at 21:23
  • You don't need to change anything, except removing therubyracer from the Gemfile. It will fallback to nodejs. – Linus Oleander Feb 15 '16 at 21:24
  • https://github.com/cowboyd/therubyracer/issues/359 did u read through this? – Mike K. Feb 15 '16 at 21:26
  • 1
    Oleander okay great, that seems to work as a work-around. Thank you very much for your time. – jsidlosky Feb 15 '16 at 21:26
  • Mike K, I did but other than the last comment, everyone else is having issues with "gem install therubyracer" which I do not, I only have an issue with using the "bundle" interface to build it. The last comment is enlightening though, I will try switching from rbenv to RVM: 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. – jsidlosky Feb 15 '16 at 21:29

1 Answers1

1

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.

jsidlosky
  • 407
  • 1
  • 5
  • 17