一尘不染

therubyracer - Gem::Ext::BuildError: ERROR: Failed to build gem native extension

javascript

我正在尝试在 Mavericks 上安装以下 gem 版本

  • libv8 (3.16.14.3)
  • therubyracer (0.12.1)

显然 therubyracer gems 依赖于 libv8。

1) 安装 libv8

什么是 libv8?我的研究似乎表明它是 Google Chrome 使用的某种 javascript 库?

我在安装它时遇到了麻烦,但是这篇很棒的帖子既有我的错误,也有一个关于如何绕过它的很好解释的答案。

所以我安装libv8

gem install libv8 -- --with-system-v8

据我了解,这会安装 gem,但使用我本地系统安装的 v8 库,而不是… gem 附带的版本?不管怎样,它是成功的。

2) 安装rubyracer

在下一步中,我在安装therubyracergem 时遇到了麻烦。我不太确定这个 gem 是做什么的,只是它是我正在尝试的 rails 项目的依赖项bundle install

它给了我以下错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
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
    --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=/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --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
/Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/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 bundled 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 /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/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 /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/therubyracer-0.12.1 for inspection.
Results logged to /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/extensions/x86_64-darwin-13/1.9.1/therubyracer-0.12.1/gem_make.out

据我所知,我选择libv8使用本地 V8 库而不是提供的库进行安装libv8,但现在无法找到本地安装。

  • 如何检查我是否确实安装了 V8 以及如何找到它?
  • 我尝试了一些指定的标志,它们似乎都没有将 gem 指向正确的安装目录
  • 这可能是一个单独的主题,但什么是extconf.rb?我在几个地方看到过。它具体试图与gcc编译器做什么?

谢谢!!

编辑:

  1. 我尝试了卸载 libv8 并通过brew install. 在几个类似的问题中也提到了这一点。没运气。
  2. 我还尝试了此处描述的 、 和 环境变量CCCXX尽管我认为这没有任何影响,因为它已经在使用我的编译器。CPP``gcc v4.6

阅读 105

收藏
2022-06-09

共1个答案

一尘不染

这个步骤对我有用。

操作系统:小牛红宝石:2.1.1

gem uninstall libv8
gem install therubyracer -v '0.11.3'
gem install libv8 -v '3.11.8.13' -- --with-system-v8
2022-06-09