“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

Installing 'therubyracer' grrrr

Robs-iMac:testapp rl$ gem install therubyracer
Building native extensions. This could take a while…
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.

/Users/rl/.rvm/rubies/ruby-1.8.7-p370/bin/ruby extconf.rb
  • 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.

Provided configuration options:
—with-opt-dir
—without-opt-dir
—with-opt-include
—without-opt-include=${opt-dir}/include
—with-opt-lib
—without-opt-lib=${opt-dir}/lib
—with-make-prog
—without-make-prog
—srcdir=.
—curdir
—ruby=/Users/rl/.rvm/rubies/ruby-1.8.7-p370/bin/ruby
extconf.rb:13: uninitialized constant Gem (NameError)
Checking for Python…

Gem files will remain installed in /Users/rl/.rvm/gems/ruby-1.8.7-p370@thebevy/gems/libv8-3.3.10.4 for inspection.
Results logged to /Users/rl/.rvm/gems/ruby-1.8.7-p370@thebevy/gems/libv8-3.3.10.4/ext/libv8/gem_make.out

It seems that libv8 requires Gem to exist, however rubygems is not available by default in Ruby 1.8.7. Ruby 1.9.x it is.

Thanks to Olly Smith for the solution

Robs-iMac:thebevy rl$ RUBYOPT=-rrubygems gem install therubyracer
Building native extensions.  This could take a while...
Fetching: therubyracer-0.10.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed libv8-3.3.10.4
Successfully installed therubyracer-0.10.2
2 gems installed
Installing ri documentation for libv8-3.3.10.4...
Installing ri documentation for therubyracer-0.10.2...
Installing RDoc documentation for libv8-3.3.10.4...
Installing RDoc documentation for therubyracer-0.10.2...