繁体   English   中英

在Windows上为“ therubyracer”安装“ libv8” gem

[英]Installing “libv8” gem for “therubyracer” on Windows

我在Windows上安装therubyracer gem时遇到问题。

使用Ruby 2.1.6 32-bit并运行

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

这是我得到的错误:

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.

这有点像一把双刃剑, libv8 gem本身试图构建v8 ,但事情变得疯狂,因为它使用*nix程序来测试和设置环境。

因此,要修复它,您必须使用-- --with-system-v8因此它不会尝试构建v8 不幸的是,该建议已经假定您在系统上的某个位置拥有v8的副本。 很明显,您没有。

快速简便的方法是安装node.js并确保将其添加到您的路径中,因为它是静态编译的,所以该库位于node.exe 这种方法可能会出现一些奇怪的错误,但是我认为您不会碰到任何一个。

当然,实际上,您不需要therubyracerlibv8因为Windows附带了本身就是JavaScript引擎的JScript ,或者如果没有其他node也足够了。

Charles Lowell的解决方案:

不,我目前无法在Windows上安装此gem。 问题是当前没有用于Windows的libv8 gem的预编译版本,而源版本仅与* nix兼容。 不一定一定要这样,它只需要花些时间使Windows编译工作即可。 https://github.com/fractaloop/libv8

就是说,Windows应该带有一个JScript,即Microsoft JavaScript运行时,它将(通过execjs )自动检测和使用它,因此您应该能够删除对therubyracer的依赖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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