ruby on rails - Error installing libv8: ERROR: Failed to build gem native extension

ID : 20044

viewed : 14

Tags : ruby-on-railsrubywindowslibv8ruby-on-railsruby

Top 5 Answer for ruby on rails - Error installing libv8: ERROR: Failed to build gem native extension

vote vote

91

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

vote vote

83

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 
vote vote

74

I tried the solution listed above command which looks very fine for installing individual gem, but for bundler users - you should use bundle config

Use

bundle config build.libv8 --with-system-v8  

and

bundle config build.therubyracer --with-system-v8 

to configure bundler to take the parameters to be used while installing specific gem

vote vote

61

With homebrew this helps me to solve this error.

brew tap homebrew/versions brew install v8-315  gem install libv8 -v '3.16.14.13' -- --with-system-v8 gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315  bundle install 

Seen on rubyracer Github issues.

For new version of homebrew as homebrew/versions has been removed:

brew install v8@3.15  gem install libv8 -v '3.16.14.13' -- --with-system-v8 gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@3.15  bundle install 

Suggestion by @gorner (thx)

vote vote

59

I do not think you need therubyracer gem on windows. It is a javascript runtime using V8 engine. Hence it is making an attempt to install libv8.

You can safely remove the gem from your Gemfile.

Rails is happy to use which ever runtime it can find. execjs,nodejs etc. are all possible options.

Microsoft already embeds JScript runtime for javascript on windows, and Rails uses it. See this for more

Top 3 video Explaining ruby on rails - Error installing libv8: ERROR: Failed to build gem native extension

Related QUESTION?