我在 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
中。 这种方法可能会出现一些奇怪的错误,但我认为您不会遇到任何错误。
当然,实际上您不需要 therubyracer
或 libv8
,因为 Windows 附带了 JScript
,它本身就是一个 JavaScript 引擎,或者如果没有别的,node
也足够了。
关于ruby-on-rails - 在 Windows 上为 "libv8"安装 "therubyracer"gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254645/