While setting up a new VM for a Rails app I ran into an error message while running bundle install. The error message:

Gem::Ext::BuilderError: ERROR: Failed to build gem native extension

Usually this means that there is an error compiling a binary for the gem. But from the error below it appeared there was a problem with my python version.

creating Makefile
Compiling v8 for ia32
Using python 2.4.3
Using compiler: /usr/bin/g++44
Traceback (most recent call last):
  File "build/gyp/gyp", line 15, in ?
    import gyp
  File "build/gyp/pylib/gyp/__init__.py", line 8, in ?
    import gyp.input
  File "build/gyp/pylib/gyp/input.py", line 14, in ?
    import gyp.common
  File "build/gyp/pylib/gyp/common.py", line 395
    with open(source_path) as source_file:
SyntaxError: invalid syntax

Since I had an older version of python installed, I figured I should upgrade it but after upgrading I got this error:

creating Makefile
Compiling v8 for ia32
Using python 3.1.5
Using compiler: /usr/bin/g++44
  File "build/gyp/gyp", line 12
    except ImportError, e:
SyntaxError: invalid syntax

Ok upgrading didn’t work. I decided to do a quick search in Google and found that libv8 is an interface for the V8 engine that is used by therubyracer gem that allows Ruby to evaluate JavaScript. I already had therubyracer installed so all I needed to do was add the following options to my libv8 gem install. Below is what I used:

gem install libv8 -v '' -- --with-system-v8

Lo and behold everything worked and installed properly. Yay!

Published On: June 25th, 2014 / Categories: Programming /

Subscribe To Receive The Latest News

Curabitur ac leo nunc. Vestibulum et mauris vel ante finibus maximus.

[contact-form-7 id=”1362″ /]

Add notice about your Privacy Policy here.