【问题标题】:Installing "libv8" gem for "therubyracer" on Windows在 Windows 上为“therubyracer”安装“libv8”gem
【发布时间】:2015-07-06 20:04:37
【问题描述】:

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

【问题讨论】:

标签: ruby-on-rails ruby windows gem


【解决方案1】:

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

所以要修复它,您必须使用-- --with-system-v8,这样它就不会尝试构建v8。不幸的是,该建议已经假定您在系统的某处拥有v8 的副本。显然你不知道。

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

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

【讨论】:

  • 所以你建议以下步骤 1) 安装 node.js 2) 运行 gem install libv8 3) 然后运行 ​​gem intall ruby​​racer 只是想确认..谢谢
  • 我的第一个建议是将它从Gemfile 中删除(如果它在那里)。如果它是另一个 gem 的依赖项,那么是的。
  • 好吧,我评论了 ruby​​racer 并成功安装了 bundle,但是当我运行 rails c 时,它询问 C:\Sooraj\Playdrone\playdrone-master>rails c [警告] 请安装 gem 'therubyracer' 以使用 Less。 C:/Ruby21/lib/ruby/gems/2.1.0/gems/less-2.5.1/lib/less/java_script/v8_context.rb :2:in `require': 无法加载此类文件 -- v8 (LoadError) ..我知道它之前被问过,但没有可靠的解决方案你能帮忙..非常感谢
  • 您是否尝试安装 nodejs 并在路径中使用 node.exe 重试?
  • 是的..问题是 Less 依赖于 ruby​​racer,我无法安装 ruby​​racer..这似乎是用户之间的常见问题
【解决方案2】:

来自Charles Lowell的解决方案:

不,据我所知,目前无法在 Windows 上安装此 gem。问题是目前没有针对Windows的libv8 gem的预编译版本,源码版本只兼容*nix。不一定非要这样,它只需要有人花时间让编译工作在 Windows 上工作。 https://github.com/fractaloop/libv8

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

【讨论】:

    猜你喜欢
    • 2013-10-08
    • 2015-03-26
    • 2016-04-09
    • 2012-03-26
    • 2023-04-01
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多