Error installing libv8: ERROR: Failed to build gem native extension

How to resolve libv8/therubyracer issue

I encountered similar issue in which after installing libv8, error occurs installing therubyracer. Here is my solution:

$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
   
$ bundle install

-- see error installing therubyracer --

$ gem uninstall libv8

$ brew install v8

$ gem install therubyracer

$ bundle install

-- see error installing libv8 --

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

try this one:

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

Note : Because libv8 is the interface for the V8 engine used by therubyracer, you may need to use libv8, even if you have V8 installed already. If you wish to use your own V8 installation, rather than have it built for you, use the --with-system-v8 option.

For more you can go through the documentation of libv8 on github