Error installing libv8: ERROR: Failed to build gem native extension
Asked Answered
N

18

196

I made a rails project with,

rails new test_bootstrap.

succeeded.

moved to the project dir and added the gems

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"

and run

bundle install

after that, i have this error.

Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
creating Makefile
지정된 경로를 찾을 수 없습니다.                                                          지정된 경로를 찾을 수
없습니다.                                                          지정된 경로를 찾을 수 없습니다.

c:/RailsInstaller/Ruby1.9.3/lib/ruby/ge
ms/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:58:in `setup_python!': libv8 requires
python 2 to be installed in order to build, but it is currently not available (RuntimeErr
or) from c:/RailsInstaller/Ruby1.9.
3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:42:in `block in build_lib
v8/builder.rb:42:in `block in build_libv8!'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/builder.rb:40:in `chdir'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/builder.rb:40:in `build_libv8!'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'                                                    


Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/l
ibv8-3.16.14.3 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ex
t/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot
continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.

sorry for some Koreans. It says, It can't find the chosen path or something like that.

and i tried to run this command

gem install libv8 -v '3.16.14.3' 

throwing the same error.

Nutt answered 30/10, 2013 at 4:15 Comment(3)
Have you installed Devkit github.com/oneclick/rubyinstaller/wiki/Development-KitThoracoplasty
I found this, i have to install python and set the path. and now it works. hope people solve with this thread. #10813196Nutt
Don't look a gift horse in the mouth :) From Debian's Lack of security support for the ecosystem around libv8 and Node.js: "The Node.js platform is built on top of libv8-3.14, which experiences a high volume of security issues, but there are currently no volunteers within the project or the security team sufficiently interested and willing to spend the large amount of time required to stem those incoming issues..."Convolution
M
636

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

Mazarin answered 30/10, 2013 at 4:47 Comment(6)
I use that. It compiles ok, but i still have errors when running 'bundle'Tronna
This part worked but I'm still getting an error when installing therubyracer. It gives me an error similar to what I was getting before with libv8 "make sure such and such succeeds before bundling" but when I try to run 'gem install therubyracer' I get "Failed to build gem native extension." errorSpontaneous
I uninstall and reinstall it with the argument given aboveas root. Not works. My Error is An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue. and Bundler::GemspecError: Could not read gem at /home/gitlab/gitlab/vendor/bundle/ruby/2.1.0/cache/libv8-3.16.14.3-x86_64-linux.gem. It may be corrupted. I remove the whole cache folder and re-run bundle install --full-index --deployment --without development test postgres aws. Works.Gast
Perfect! gem install libv8 -v '3.16.14.3' -- --with-system-v8 worked for me on OS X 10.11.Lepidosiren
I found that it could not find a system v8, so doing brew install v8 helped. Follow the instructions at this answer here: #24081973Mazer
On OS X 10.15, bundle config build.libv8 --with-system-v8 works.Lepidosiren
B
163

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
Beesley answered 17/4, 2015 at 16:56 Comment(7)
the steps mentioned in this reply works best, we need to first gem install libv8, uninstall to install the system wide v8 before gem installing therubyracer (gem install libv8 with the --with-system-v8 flag) :)Psoriasis
I don't think you need the first step. Before running bundle install, use brew to install the system v8. Then install both the therubyracer gem and the libv8 gem by hand. and run bundle install. But I haven't tried it yet.Rist
This also worked for me on OSX 10.10.5 with ruby 2.1.2p95 for libv8 3.16.14.11Hell
Remember to change '3.16.14.3' to whatever version bundle is trying to run or it wont work when you run bundle installSemidome
Also worked for 10.12 (Sierra) with ruby 1.9.3 for libv '3.16.14.11'Embroil
It did not work for me, unfortunately. An error occurred while installing libv8 (3.16.14.13), and Bundler cannot continue. Make sure that gem install libv8 -v '3.16.14.13' succeeds before bundling.Birthplace
Worked for me, macOS 10.13.1. It is truly absurd that these are the steps required.Yetah
T
55

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

Tetraspore answered 14/4, 2016 at 14:15 Comment(1)
For whatever reason my bundle config required the following to find the correct build (which uses the brew install from coding addicted's answer below) bundle config build.therubyracer --with-v8-dir=/usr/local/opt/v8-315Dulci
G
50

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 [email protected]

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/[email protected]

bundle install

Suggestion by @gorner (thx)

Gyno answered 3/4, 2016 at 17:0 Comment(6)
This worked for me, though it installs an older version of v8 via brew.Gittern
This error is driving me crazy each time I switch ruby version. I think you can try adjusting the v8 version option and the path to get it.Gyno
only this solution works for me, thanks for the solutionWoodford
@codingaddicted you ever figure this error keep occurring? I updated ruby and rails for a new project and always get this error when I open a new shell for my old project. rvm is supposed to handle these version issues, but I need to keep doing your commands above each time I open a new shell for my old project.Springing
@Springing as far as I remember I have to run those for each version of ruby. I was seeing this error when I updated ruby (but I haven't done so much ruby last months and I didn't play with different versions).Gyno
See GitHub issue for further info: github.com/cowboyd/libv8/issues/205#issuecomment-200872773Tempera
T
7

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

Tweeny answered 30/10, 2013 at 4:24 Comment(0)
B
6

Other workaround to fix the problem is to separate them in the Gemfile

group :production do
 gem 'libv8', '~> 3.11.8.3'
 gem 'therubyracer', :platform => :ruby
end

And then run the bundle command: bundle install --without production

Boycie answered 22/3, 2014 at 15:32 Comment(1)
This works well in combination with @Litmus' answer because this shows how you can retain the gem in the configuration ( which will probably be relevant for deployment ) without breaking the development setup on Windows.Danielladanielle
V
4

I was also unable to install this gem instead of using

--with-system-v8

once try to do bundle update which worked fine for me

Veritable answered 20/7, 2016 at 16:40 Comment(0)
L
4

found this on github

assuming you have tried the mentioned steps above, installed v8-315 and v8 via brew.

brew unlink v8
brew link --force v8-315
gem install therubyracer -v '0.12.2' -- --with-system-v8
Lunitidal answered 14/9, 2019 at 10:45 Comment(0)
E
2

That works for me. Put that in your Gemfile

gem 'libv8', '~>3.16.14.7'

Edwardoedwards answered 12/1, 2015 at 15:11 Comment(1)
this solution lead me to bundle install --no-deployment and then bundle install worked for meTellurate
I
1

My issue wasn't related with therubyracer at all just libv8 gem and as @rishav-bhardwaj pointed --with-system-v8 didn't do the trick, instead i had to exec

bundle update

then

bundle install

and finally

Bundle complete!

The error is gone!

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

Inconsecutive answered 17/3, 2017 at 17:15 Comment(0)
S
1

In my case I resolved this situation by requiring 'mini_racer', '~> 0.2.6' in my Gemfile

Then bundle install command worked.

Starwort answered 26/12, 2019 at 11:48 Comment(0)
D
1

I tried the below commands on my local, it worked fine:

brew install [email protected]
gem install libv8 -v 'YOUR_VERSION' -- --with-system-v8
gem install therubyracer -v 'YOUR_VERSION' -- --with-v8-dir=/usr/local/opt/[email protected]
bundle install
Duna answered 23/6, 2020 at 10:25 Comment(0)
R
1

We ran into a compilation error – out of the blue – in December 2020 on Debian 10 VMs as well as our local Debian 10 Desktops.

Bundle fails trying to compile Installing libv8 3.16.14.19 with native extensions

The error log says:

IOError: [Errno 2] No such file or directory: '/home/username/application/shared/bundle/ruby/2.6.0/gems/libv8-7.3.492.27.1/vendor/build/config/gclient_args.gni'
Running: gclient root
Running: gclient config --spec 'solutions = [
  {
    "url": "https://chromium.googlesource.com/v8/v8.git",
    "managed": False,
    "name": "v8",
    "deps_file": "DEPS",
    "custom_deps": {},
  },
]
'
Running: gclient sync --with_branch_heads
Subprocess failed with return code 1.

We've checked the tags on the Google v8 Repo and found that the requested tag 7.3.492.27.1 seems not to be available on the Google Repo:

libv8 did not install properly, expected binary v8 archive '/home/.../gyp
/libv8_snapshot.a'to exist, but it was not found 
(Libv8::Location::Vendor::ArchiveNotFound)

Our only solution was to remove therubyracer completely from the Gemfile :-(

Rambo answered 11/12, 2020 at 9:1 Comment(0)
S
1

I solved this problem using:

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

Stieglitz answered 7/1, 2021 at 16:10 Comment(0)
M
0

Try with

gem "therubyracer", "~> 0.10.2" to Gemfile

And it will install dependent gem libv8 (3.3.10.4) and the issue of build gem native extension failure got resolve.

Methacrylate answered 7/8, 2014 at 5:30 Comment(0)
R
0

Resolved libv8 3.16.14.7 issue using below command:

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

And then bundle install successfully completed.

Randers answered 28/7, 2017 at 11:29 Comment(0)
F
0

i feel this has less to do with libv8 and more to do with therubyracer.

i received your same error while running a bundle install on a rails app. if you have encountered this similarly, try installing the gem outside of bundle like so:

gem install therubyracer

then run bundle install. i hope this works for you too.

Fabricate answered 28/7, 2017 at 14:28 Comment(0)
E
0

I also had problems using libv8 and mini_racer. Resolved the problem with

brew install v8

bundle update libv8 mini_racer

Using the latest versions mini_racer 0.2.10 and libv8 7.3.492.27 worked like a charm.

Ectopia answered 10/5, 2020 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.