在Windows上安装TheRubyRacer和已安装Libv8--with-system-v8

4

我最终通过使用gem install libv8 -- --with-system-v8在Windows上安装了libv8。

现在当我尝试安装therubyracer时,出现以下情况:

gem install therubyracer
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb --with-system-v8
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:/Ruby193/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}/
C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You hav
e 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

我想知道这个错误消息的真正含义是什么? 同时,我查阅了https://github.com/cowboyd/libv8#bring-your-own-v8。 如何安装v8的头文件?
3个回答

3

当我遇到这个问题时,我发现在开发中我并不需要那些宝石(gems),因为Rails会预编译你的资源文件,所以我的解决方案非常简单。

Gemfile

gem "rails"

group :production do
  gem 'therubyracer'
end

接下来,当您运行bundle命令时:

$ bundle install --without production

那就微笑面对生活吧 :D


我不同意你的观点,因为 Ruby Racer 是 Rails 只用于预编译资产的 gem,在实际情况中,你需要在生产服务器上使用它。 - rderoldan1
1
虽然这是一个可能的解决方案,但它并不是问题的答案。 - Alexander Kellett

2

在 Mac 上,您可以尝试使用 Homebrew 更新 v8 库:

gem uninstall libv8
brew install v8
gem install therubyracer

更新:抱歉,没有意识到这是一个仅限于Windows的问题。


2
问题涉及Windows操作系统。 - Alexander Kellett
我最终只需要 brew install v8(不需要 gem uninstall libv8 - Benjamin Crouzier

1

@Aalap

我在安装Ruby on Rails网站应用程序时遇到了与您相同的问题,我的操作系统是Windows 7 64位。我找到了这个solution。虽然有点老,但解决了问题。该解决方案提供了“therubyracer” gem文件和v8.dll库进行安装。上述链接中的说明非常清楚。

我像Periback's answer on SO那样安装了'libv8' gem,当我尝试安装'therubyracer' gem时,出现了与您一样的错误。现在我的Web应用程序运行良好,“gem list”命令显示:

libv8(3.11.8.13)

therubyracer(0.11.0beta1 x86-mingw32)

希望这可以帮到您。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接