简体   繁体   中英

Installing “libv8” gem for “therubyracer” on Windows

I'm having trouble installing therubyracer gem on Windows.

Using Ruby 2.1.6 32-bit and running

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

This is the error I get:

Installing therubyracer 0.12.1 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    C:/Ruby21/bin/ruby.exe extconf.rb
checking for main() in -lpthread... no
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby21/bin/ruby
        --with-pthreadlib
        --without-pthreadlib
        --enable-debug
        --disable-debug
        --with-v8-dir
        --without-v8-dir
        --with-v8-include
        --without-v8-include=${v8-dir}/include
        --with-v8-lib
        --without-v8-lib=${v8-dir}/lib
C:/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in 
`configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location

thanks,
The Mgmt

        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
        from extconf.rb:32:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby21/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.1 for inspection.
Results logged to C:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/therubyracer-0.12.1/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.

This is kinda a double edged sword, the libv8 gem itself tries to build v8 and things get crazy because it's using *nix programs to test and setup the environment.

So to fix it you have to use -- --with-system-v8 so it doesn't try to build v8 . Unfortunately that advice already presumes you have a copy of v8 somewhere on your system. Which you don't, obviously.

The quick and easy is to install node.js and make sure it gets added to your path, since it is statically compiled the library is in node.exe . There may be some weird errors with that approach, BUT I don't think you will run into any of them.

Of course, in reality you shouldn't need therubyracer or libv8 because Windows ships with JScript which is a JavaScript engine itself, or if nothing else node will also suffice.

Solution from Charles Lowell :

No, there is no way that I know of to currently install this gem on windows. The problem is that there is currently no pre-compiled version of the libv8 gem for Windows, and the source version is only compatible with *nix. It does not necessarily have to be that way, it just requires somebody taking the time to make the compile work for Windows. https://github.com/fractaloop/libv8

That said, Windows should come with a JScript, the Microsoft JavaScript runtime, which rails (via execjs ) will automatically detect and use, so you should be able to just remove your dependency on therubyracer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM