安装" libv8"宝石为" therubyracer"在Windows上

时间:2015-07-06 20:04:38

标签: ruby-on-rails ruby windows gem

我在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.

2 个答案:

答案 0 :(得分:0)

这是一把双刃剑,libv8宝石本身试图构建v8并且事情变得疯狂,因为它正在使用*nix程序来测试和设置环境。

因此,为了解决此问题,您必须使用-- --with-system-v8,因此不会尝试构建v8。不幸的是,这个建议已经假设你的系统上有v8的副本。显然,你不这样做。

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

当然,实际上您不应该需要therubyracerlibv8,因为Windows附带的JScript本身就是一个JavaScript引擎,或者其他任何内容node都不会也足够了。

答案 1 :(得分:0)

  

来自Charles Lowell的解决方案:

不,我目前无法知道当前在Windows上安装此gem。问题是目前没有针对Windows的libv8 gem的预编译版本,源版本仅与* nix兼容。它不一定是那种方式,它只需要有人花时间让Windows编译工作。 https://github.com/fractaloop/libv8

也就是说,Windows应该附带一个JScript,Microsoft JavaScript运行时,rails(通过execjs)会自动检测和使用,所以你应该能够删除你对therubyracer的依赖