在Mac 10.9 / Rails 3.2.11中安装therubyracer gem时出现错误

9
有什么想法,为什么我不能在Mac 10.9和Rails 3上安装therubyracer gem?
Installing therubyracer (0.11.3) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/xiruki/.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:462:14: error: no type named 'AccessorGetter' in namespace 'v8'
  inline v8::AccessorGetter accessorGetter() {return &AccessorGetter;}
         ~~~~^
./rr.h:463:14: error: no type named 'AccessorSetter' in namespace 'v8'
  inline v8::AccessorSetter accessorSetter() {return RTEST(set) ? &AccessorSetter : 0;}
         ~~~~^
./rr.h:465:14: error: no type named 'NamedPropertyGetter' in namespace 'v8'
  inline v8::NamedPropertyGetter namedPropertyGetter() {return &NamedPropertyGetter;}
         ~~~~^
./rr.h:466:14: error: no type named 'NamedPropertySetter' in namespace 'v8'
  inline v8::NamedPropertySetter namedPropertySetter() {return RTEST(set) ? &NamedPropertySetter : 0;}
         ~~~~^
./rr.h:467:14: error: no type named 'NamedPropertyQuery' in namespace 'v8'
  inline v8::NamedPropertyQuery namedPropertyQuery() {return RTEST(query) ? &NamedPropertyQuery : 0;}
         ~~~~^
./rr.h:468:14: error: no type named 'NamedPropertyDeleter' in namespace 'v8'
  inline v8::NamedPropertyDeleter namedPropertyDeleter() {return RTEST(deleter) ? &NamedPropertyDeleter : 0;}
         ~~~~^
./rr.h:469:14: error: no type named 'NamedPropertyEnumerator' in namespace 'v8'
  inline v8::NamedPropertyEnumerator namedPropertyEnumerator() {return RTEST(enumerator) ? &NamedPropertyEnumerator : 0;}
         ~~~~^
./rr.h:471:14: error: no type named 'IndexedPropertyGetter' in namespace 'v8'
  inline v8::IndexedPropertyGetter indexedPropertyGetter() {return &IndexedPropertyGetter;}
         ~~~~^
./rr.h:472:14: error: no type named 'IndexedPropertySetter' in namespace 'v8'
  inline v8::IndexedPropertySetter indexedPropertySetter() {return RTEST(set) ? &IndexedPropertySetter : 0;}
         ~~~~^
./rr.h:473:14: error: no type named 'IndexedPropertyQuery' in namespace 'v8'
  inline v8::IndexedPropertyQuery indexedPropertyQuery() {return RTEST(query) ? &IndexedPropertyQuery : 0;}
         ~~~~^
./rr.h:474:14: error: no type named 'IndexedPropertyDeleter' in namespace 'v8'
  inline v8::IndexedPropertyDeleter indexedPropertyDeleter() {return RTEST(deleter) ? &IndexedPropertyDeleter : 0;}
         ~~~~^
./rr.h:475:14: error: no type named 'IndexedPropertyEnumerator' in namespace 'v8'
  inline v8::IndexedPropertyEnumerator indexedPropertyEnumerator() {return RTEST(enumerator) ? &IndexedPropertyEnumerator : 0;}
         ~~~~^
./rr.h:481:20: error: no type named 'AccessorInfo' in namespace 'v8'
    Info(const v8::AccessorInfo& info);
               ~~~~^
./rr.h:487:22: error: no type named 'AccessorInfo' in namespace 'v8'
    inline const v8::AccessorInfo* operator->() {return this->info;}
                 ~~~~^
./rr.h:501:15: error: no type named 'AccessorInfo' in namespace 'v8'
    const v8::AccessorInfo* info;
          ~~~~^
./rr.h:505:89: error: no type named 'AccessorInfo' in namespace 'v8'
  static v8::Handle<v8::Value> AccessorGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
                                                                                    ~~~~^
./rr.h:506:100: error: no type named 'AccessorInfo' in namespace 'v8'
  static void AccessorSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
                                                                                               ~~~~^
./rr.h:508:94: error: no type named 'AccessorInfo' in namespace 'v8'
  static v8::Handle<v8::Value> NamedPropertyGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
                                                                                         ~~~~^
./rr.h:509:122: error: no type named 'AccessorInfo' in namespace 'v8'
  static v8::Handle<v8::Value> NamedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
                                                                                                                     ~~~~^
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/xiruki/.rvm/gems/ruby-1.9.3-p448@ensemblist/gems/therubyracer-0.11.3 for inspection.
Results logged to /Users/xiruki/.rvm/gems/ruby-1.9.3-p448@ensemblist/gems/therubyracer-0.11.3/ext/v8/gem_make.out

An error occurred while installing therubyracer (0.11.3), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.11.3'` succeeds before bundling.

任何解决方法都将不胜感激。


1
回复:解决方法 - 不要使用 therubyracer。您可以在任何没有预装 JS 引擎的环境中(例如 Linux)安装 node.js 以替代。标准 Rails 应用程序在 OS X 和 Windows 上不需要它。 - PinnyM
4
除了上述的解决方法之外,你是否还有其他的解决方案呢?如果有,请提供答案。 - miked
不同的OSX和Rails版本,但最终我们不得不构建自己的libv8(3.16.14.7)才能使一切正确捆绑 - 已经过去了大约一年,我不记得具体情况了。我们在开发环境中携带着那个libv8 - 在Linux生产环境中没有问题。 - dwilkins
2个回答

1

尝试使用 bundle update

如果不起作用,尝试

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

1
你在Gemfile中声明了什么?
试试这个:
gem 'therubyracer',platforms: :ruby

你的建议更适合作为评论,不太能称为答案。 - whizcreed
我不同意你的观点:在许多情况下,它只是解决问题而无需将Node.js安装到系统中。如果解决方案很简单,这并不意味着需要在评论中建议它,无论如何,祝您投票成功 :-( - Zen

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