ruby-on-rails - 在 Windows 上为 "libv8"安装 "therubyracer"gem

标签 ruby-on-rails ruby windows gem

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

使用 Ruby 2.1.6 32 位 并运行

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 附带了 JScript,它本身就是一个 JavaScript 引擎,或者如果没有别的,node 也足够了。

关于ruby-on-rails - 在 Windows 上为 "libv8"安装 "therubyracer"gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254645/

相关文章:

ruby-on-rails - 使用 rvm 升级到 ruby​​ 1.9.3 破坏了我的 rails 应用程序

ruby-on-rails - Ruby on Rails 教程 - 出现错误,让我抓狂

python - Windows 没有将命令行参数传递给从 shell 执行的 Python 程序

ruby-on-rails - 仅当使用可验证的数据库时检查用户是否对身份验证有效

ruby-on-rails - Ruby、SSLSockets 和 Apple 的增强型 APN 消息格式

ruby-on-rails - rails : stack level too deep

php - 什么是 SQL 支持的数字运算的更好选择 - Ruby 1.9、Python 2、Python 3 或 PHP 5.3?

ruby-on-rails - 尝试创建新的 Rails 应用程序时出现 Thor 参数错误

Windows 服务用户帐户无法访问证书存储

c++ - 将 NULL 分配给 x64 指针