ruby-on-railsrubyrubygemsinstallationtherubyracer

Unable to install therubyracer gem


I installed libv8 gem seperately without a hitch, but when I try to install therubyracer gem I get the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby extconf.rb
checking for main() in -lpthread... yes
Warning! Unable to load libv8 ~> 3.16.14.
*** 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}/
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby
    --with-pthreadlib
    --without-pthreadlib
    --enable-debug
    --disable-debug
extconf.rb:32:in `<main>': undefined method `configure_makefile' for Libv8:Module (NoMethodError)


Gem files will remain installed in /home/thecodehitman/ruby/gems/gems/therubyracer-0.12.1 for inspection.
Results logged to /home/thecodehitman/ruby/gems/gems/therubyracer-0.12.1/ext/v8/gem_make.out

Not sure what to do.


Solution

  • Try this:

    $ sudo gem install therubyracer --platform ruby
    

    Try with or without sudo.

    If it is a Ruby on Rails app, include the line:

    gem 'therubyracer', :platform=>:ruby
    

    inside Gemfile.