Tags

Ive just encountered an error when I tried to execute a bundle install or bundle update command on my Windows. Some of these errors are the ff:

  • Installing libv8 with native extensions… Failed to build gem native extension
  • libv8 requires python 2 to be installed in order to build ..blah blah blah…
  • Could not find therubyracer …

See below sample of an error.

Installing libv8 (3.11.8.17) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
        C:/ruby193/bin/ruby.exe extconf.rb
creating Makefile
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:49:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeError)
        from C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:35:in `block in build_libv8!'
        from C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:34:in `chdir'
        from C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:34:in `build_libv8!'
        from C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/location.rb:24:in `install!'
        from extconf.rb:7:in `'
Gem files will remain installed in C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17 for inspection.
Results logged to C:/ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.11.8.17), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.11.8.17'` succeeds before bundling.

To fix the problem, there are 2 ways that you can try.
1) Try to run this command:

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

2) Or, you will separate them in the Gemfile.

group :production do
 gem 'libv8', '~> 3.11.8.17'
 gem 'therubyracer', :platform => :ruby
end
# And then run the bundle command: bundle install --without production or bundle install development

And it should be working now!
Reference: http://stackoverflow.com/questions/19673714/rails-gem-install-error-error-installing-libv8-error-failed-to-build-gem-nati

Advertisements