使用 osx Yosemite 安装 ruby​​racer 时出错

Posted

技术标签:

【中文标题】使用 osx Yosemite 安装 ruby​​racer 时出错【英文标题】:error installing rubyracer with osx Yosemite 【发布时间】:2015-10-04 02:36:46 【问题描述】:

我已经升级了我的 ruby​​ 版本,当我安装 ruby​​ racer 时出现以下错误。安装 libv8 如下 gem install libv8 -- --with-v8-lib

ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.

/Users/ViswaMani/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.6
Using compiler: /usr/bin/c++ (clang version 6.1.0)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o has no symbols
In file included from ../src/accessors.cc:28:
In file included from ../src/v8.h:60:
In file included from ../src/objects-inl.h:38:
In file included from ../src/elements.h:33:
In file included from ../src/heap.h:35:
In file included from ../src/incremental-marking.h:33:
In file included from ../src/mark-compact.h:32:
../src/spaces.h:896:26: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
  bool exists()  return this != NULL && code_range_ != NULL; 
                         ^~~~    ~~~~
../src/spaces.h:898:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
    if (this == NULL || code_range_ == NULL) return false;
        ^~~~    ~~~~
2 errors generated.
make[1]: *** [/Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
make: *** [x64.release] Error 2
/Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/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/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `each'
    from /Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/ViswaMani/.rvm/gems/ruby-2.1.1@futura/gems/libv8-3.16.14.11/ext/libv8/location.rb:26:in `install!'

【问题讨论】:

【参考方案1】:

如果您已经安装了libv8,请将其删除并重新安装。

gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.3' -- --with-system-v8

或者,您可以安装您的特定版本,

gem install libv8 -v 'XX.XX.XX' -- --with-system-v8 

【讨论】:

以上是关于使用 osx Yosemite 安装 ruby​​racer 时出错的主要内容,如果未能解决你的问题,请参考以下文章

如何在 OSX 10.10 Yosemite 上安装 xcode 5

无法通过自制 OSX Yosemite 安装 mcrypt

在 OSX Yosemite 上安装 Python-Opencv

如何在Mac OS X上安装 Ruby运行环境

OSX 10.10 Yosemite 本地开发环境崩溃 - PHP mcrypt 问题

Ruby cairo gem 无法在 Mac OS X Yosemite 上安装