web-dev-qa-db-ja.com

Mavericksでのrubyracer / libv8(0.12.1)インストールの修正

わかりました、これで私の束縛は終わりです。同様の質問がいくつかありますが、それらはすべてruyracer 0.10を参照しており、ほとんどの場合、0.12にアップグレードすることで問題を解決できると結論付けています。

同様の問題がありますが、0.12を使用すると、.

同様の質問

「標準」(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.

最悪の時代!

OK。したがって、rubyracer 0.10の問題を修正するために、一部の人々は、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.

私の頭を完全に引っ掻いて、すでにこれで何時間も無駄にしています。何が問題なのかを見つけて修正を手伝うことができれば、あなたは永遠に私のヒーロー(ine)になります。

24
Chris S

OK、これでソートされました。

同じ問題を抱える将来の人々のために、私は以前のOS Xのインストールに対してRubyを構築することで苦しんでいました。

問題のあるRubyをアンインストール/再インストールすることはできると思いますが、rvmを完全に削除してゼロから開始することで修正されました。

ここで問題がどのように解決されたかについての詳細:

https://github.com/cowboyd/libv8/issues/12

4
Chris S

Ruby Racer after rm Gemfile.lockで続行できました。RVMのnukeオプションよりも簡単です。

事前:brew install v8経由でv8をインストールしてから、gem install libv8 -v '3.16.14.3' -- --with-system-v8をインストールしました

10.10ヨセミテを実行しています

46
CloudMagick

gem install libv8 -v '3.16.14.3' -- --with-system-v8を実行することで、物事をやり直すことができました。

リファレンス: https://github.com/cowboyd/libv8/issues/12

16
srt32

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
1
MProuts

OSX 10.9.3Ruby 2.1.3、およびすべてで同じ問題therubyracerのバージョン。

今、私はexecjs(uglifier gemdependencie)に任せています。

ExecJSを使用すると、RubyからJavaScriptコードを実行できます。 JavaScriptプログラムを評価するために利用可能な最適なランタイムを自動的に選択し、その結果をRubyオブジェクトとして返します。

OSXユーザー

「Apple JavaScriptCore」は、OSXのJSランタイムのデフォルトとして提供されます。 execjsをインストールするだけで問題は解決します。

Linuxユーザー

Node.jsをインストールします。 Execjs gemはjsランタイムとしてnode.jsを自動的に選択します。

Sudo apt-get install nodejs

Githubの詳細:

https://github.com/sstephenson/execjs

1

この問題は、最新バージョンのtherubyracer(0.12.3)には存在しません。

bundle update therubyracer
0
Edward Anderson