这正是我遇到的问题,我使用自制版本解决了它。
Problem
我在安装 gem libv8 时遇到了问题。为了解决这个问题,我通过brew在我的系统上安装了v8,然后使用了该选项--with-system-v8
.
$ brew install v8
$ gem install libv8 -v '3.11.8.13' -- --with-system-v8
$ gem install therubyracer -v '0.11.4'
gem libv8 安装没有问题,但是最后一行导致了原始问题的错误。然后我尝试了,
$ gem install therubyracer -v '0.11.4' -- --with-system-v8 --with-v8-dir=/usr/local/Cellar/v8/3.30.33.16
将其指向brew提供的v8。这样的话,错误就变了,现在告诉我,我没有提供与 v8 兼容的版本3.11.8.13
.
对于那些通过谷歌搜索错误消息的人:
Building native extensions with: '--with-v8-dir=/usr/local/Cellar/v8/3.30.33.16/'
This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/zeigfreid/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-v8-dir=/usr/local/Cellar/v8/3.30.33.16/
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/zeigfreid/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/libv8-3.11.8.13/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.11.8.13 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/libv8-3.11.8.13/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/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/gems/therubyracer-0.11.4 for inspection.
Results logged to /Users/zeigfreid/.rvm/gems/ruby-1.9.3-p194@va_rails_3.2.11/extensions/x86_64-darwin-13/1.9.1/therubyracer-0.11.4/gem_make.out
Solution
我决定尝试安装 v8 的早期版本。再次使用brew,
$ brew search v8
homebrew/versions/v8-315 v8
$ brew install v8-315
$ brew info v8-315
$ gem install therubyracer -v '0.11.4' -- --with-system-v8 --with-v8-dir=/usr/local/Cellar/v8-315/3.15.11
这奏效了。我最终安装的 v8 版本是 ~3.15,但这与 3.11.8 兼容
这里真正的解决方案是将所有内容更新到最新版本,我不提倡使用旧的和过时的宝石。保持您的系统干净并处于最新状态,即使这会带来伤害!