修复 Mavericks 上的 rubyracer/libv8 (0.12.1) 安装
Posted
技术标签:
【中文标题】修复 Mavericks 上的 rubyracer/libv8 (0.12.1) 安装【英文标题】:Fix therubyracer/libv8 (0.12.1) installation on Mavericks 【发布时间】:2014-04-24 06:08:46 【问题描述】:好的,我对此束手无策。有一些类似的问题,但都提到了 rubyracer 0.10,并且他们大多认为可以通过升级到 0.12 来解决问题。
我也有类似的问题,但是当我使用 0.12 时。
类似问题
Installing libv8 gem on Mavericks How to fix libv8 error from Gemfile on Mavericks?我在使用“标准”(xcode?)gcc 以及自制的 apple-gcc42 和 gcc 时遇到问题。 --with-system-v8
和 --without-system-v8
我都试过了,但还是没有骰子。
这里有一些日志:
从零开始……
$ cd ~/Documents/code/website
$ rvm gemset empty
$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin10.8.0]
$ grep rubyracer Gemfile
gem 'therubyracer', '~> 0.12.0'
$ brew list | grep v8
$ cat ~/.bundle/config
$ cat .bundle/config
BUNDLE_BIN: bin
$ $CXX
$ $CPP
$ $CC
$ which gcc
/usr/bin/gcc
$ which g++
/usr/bin/g++
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-
gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
尝试捆绑安装
Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
^
1 error generated.
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
糟糕的时光。
错误信息提示建议使用 gcc 4.4+。我们可以做到。
$ export CXX=/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ export CPP=/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ export CC=/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ which $CXX
/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ which $CPP
/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ which $CC
/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ bundle install
…
Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Using compiler: /usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
g++-4.8: error: unrecognized command line option '-Wnewline-eof'
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
更糟糕的时候!
好的。所以要解决 therubyracer 0.10 的问题,有人建议 brew 安装 v8,然后告诉 rubygems 使用系统 v8。让我们看看会发生什么!
$ brew install v8
==> Downloading https://github.com/v8/v8/archive/3.21.17.tar.gz
Already downloaded: /Library/Caches/Homebrew/v8-3.21.17.tar.gz
==> Checking out http://gyp.googlecode.com/svn/trunk
==> make native -j4 library=shared snapshot=on console=readline i18nsupport=off
???? /usr/local/Cellar/v8/3.21.17: 21 files, 27M, built in 3.4 minutes
$ cat ~/.bundle/config
---
BUNDLE_BUILD__LIBV8: --with-system-v8
$ bundle install
…
Installing therubyracer (0.12.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... yes
creating Makefile
make
compiling accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
In file included from accessor.cc:1:
./rr.h:463:14: error: no type named 'AccessorGetter' in namespace 'v8'
inline v8::AccessorGetter accessorGetter() return &AccessorGetter;
~~~~^
./rr.h:464:14: error: no type named 'AccessorSetter' in namespace 'v8'
inline v8::AccessorSetter accessorSetter() return RTEST(set) ? &AccessorSetter : 0;
~~~~^
./rr.h:466:14: error: no type named 'NamedPropertyGetter' in namespace 'v8'
inline v8::NamedPropertyGetter namedPropertyGetter() return &NamedPropertyGetter;
~~~~^
./rr.h:467:14: error: no type named 'NamedPropertySetter' in namespace 'v8'
inline v8::NamedPropertySetter namedPropertySetter() return RTEST(set) ? &NamedPropertySetter : 0;
~~~~^
./rr.h:468:14: error: no type named 'NamedPropertyQuery' in namespace 'v8'
inline v8::NamedPropertyQuery namedPropertyQuery() return RTEST(query) ? &NamedPropertyQuery : 0;
~~~~^
./rr.h:469:14: error: no type named 'NamedPropertyDeleter' in namespace 'v8'
inline v8::NamedPropertyDeleter namedPropertyDeleter() return RTEST(deleter) ? &NamedPropertyDeleter : 0;
~~~~^
./rr.h:470:14: error: no type named 'NamedPropertyEnumerator' in namespace 'v8'
inline v8::NamedPropertyEnumerator namedPropertyEnumerator() return RTEST(enumerator) ? &NamedPropertyEnumerator : 0;
~~~~^
./rr.h:472:14: error: no type named 'IndexedPropertyGetter' in namespace 'v8'
inline v8::IndexedPropertyGetter indexedPropertyGetter() return &IndexedPropertyGetter;
~~~~^
./rr.h:473:14: error: no type named 'IndexedPropertySetter' in namespace 'v8'
inline v8::IndexedPropertySetter indexedPropertySetter() return RTEST(set) ? &IndexedPropertySetter : 0;
~~~~^
./rr.h:474:14: error: no type named 'IndexedPropertyQuery' in namespace 'v8'
inline v8::IndexedPropertyQuery indexedPropertyQuery() return RTEST(query) ? &IndexedPropertyQuery : 0;
~~~~^
./rr.h:475:14: error: no type named 'IndexedPropertyDeleter' in namespace 'v8'
inline v8::IndexedPropertyDeleter indexedPropertyDeleter() return RTEST(deleter) ? &IndexedPropertyDeleter : 0;
~~~~^
./rr.h:476:14: error: no type named 'IndexedPropertyEnumerator' in namespace 'v8'
inline v8::IndexedPropertyEnumerator indexedPropertyEnumerator() return RTEST(enumerator) ? &IndexedPropertyEnumerator : 0;
~~~~^
./rr.h:482:16: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
Info(const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:488:18: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
inline const v8::AccessorInfo* operator->() return this->info;
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:502:11: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
const v8::AccessorInfo* info;
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:506:85: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> AccessorGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:507:96: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static void AccessorSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:509:90: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> NamedPropertyGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
./rr.h:510:118: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> NamedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [accessor.o] Error 1
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448/gems/therubyracer-0.12.1 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448/gems/therubyracer-0.12.1/ext/v8/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.
完全摸不着头脑,已经在这上面浪费了好几个小时。如果您能发现问题所在并帮助我解决问题,那么您将永远是我的英雄。
【问题讨论】:
【参考方案1】:好的,现在已经排序了。
对于未来遇到同样问题的人,我正在遭受针对以前安装的 OS X 构建 ruby 的痛苦。
通过完全 nuking rvm 并从头开始进行修复,尽管我想您可以卸载/重新安装有问题的 ruby。
有关如何解决问题的更多详细信息:
https://github.com/cowboyd/libv8/issues/120
【讨论】:
【参考方案2】:当我从 OSX Mountain Lion 升级到 OSX Mavericks 时,我遇到了同样的问题。 ruby 1.8.7 的补丁级别显然很重要。
从 ruby-1.8.7-p354 升级到 ruby-1.8.7-375 对我有用。
libv8 (3.16.14.3-x86_64-darwin-13) 和 therubyracer (0.12.0) gems 安装没有问题。
假设你使用 rbenv:
rbenv versions
system
* 1.8.7-p354
2.0.0-rc2
rbenv uninstall 1.8.7-p354
rbenv install 1.8.7-p375
rbenv versions
system
* 1.8.7-p375
2.0.0-rc2
bundle install
【讨论】:
【参考方案3】:OSX 10.9.3、ruby 2.1.3 和 therubyracer 的每个版本都有同样的问题。
现在我让 execjs(uglifier gem 依赖项)来处理它。
ExecJS 允许您从 Ruby 运行 javascript 代码。它会自动选择可用于评估您的 JavaScript 程序的最佳运行时,然后将结果作为 Ruby 对象返回给您。
OSX 用户
“Apple JavaScriptCore”是 OSX 上 JS 运行时的默认设置。只需安装 execjs 即可解决问题。
Linux 用户
安装 node.js。 Execjs gem 会自动选择 node.js 作为 js 运行时。
sudo apt-get install nodejs
github 上的更多信息:
https://github.com/sstephenson/execjs
【讨论】:
【参考方案4】:在rm Gemfile.lock
之后,我能够继续使用 ruby racer,也许可以试试这个,这比 RVM nuke 选项更容易。
事先:
我通过brew install v8
安装了v8,然后做了gem install libv8 -v '3.16.14.3' -- --with-system-v8
我正在运行 10.10 Yosemite
【讨论】:
我必须先brew install v8
然后bundle config build.libv8 -- --with-system-v8
然后bundle install
不,删除 Gemfile.lock 意味着更新所有 gem。如果您这样做,请准备好进行大量测试。【参考方案5】:
我可以通过运行gem install libv8 -v '3.16.14.3' -- --with-system-v8
让事情重新开始。
参考:https://github.com/cowboyd/libv8/issues/120
【讨论】:
仅供参考......这确实为我解决了部分问题,但我留下了“错误:命名空间'v8'中没有名为'ScriptData'的成员”错误。继续我的搜索。 听起来不好玩;)。祝你好运! 肯定的;最后刚刚移除了rubyracer,现在我可以继续前进了。【参考方案6】:可能是rubygems
为您的系统获取错误的二进制文件。
诊断:
将gem env platform
的输出与 > About This Mac > System Report > Software
下的“内核版本”进行比较
如果不匹配(例如 Kernel Version: 14.4.0
和 x86_64-darwin-12
),那么 RubyGems 会为您的系统获取错误版本的 therubyracer
和 libv8
修复:
短期:bundle update therubyracer --platform=x86_64-darwin-14
【讨论】:
【参考方案7】:此问题在最新版本的therubyracer
(0.12.3) 中不再存在。
bundle update therubyracer
【讨论】:
以上是关于修复 Mavericks 上的 rubyracer/libv8 (0.12.1) 安装的主要内容,如果未能解决你的问题,请参考以下文章
Ruby Gem 安装 Json 在 Mavericks 和 Xcode 5.1 上失败 - 未知参数:'-multiply_definedsuppress'
无法使用 Mavericks 在我的 Mac 上安装 PG gem
Mavericks 上的 Django 和 mysql 问题