3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OSX Yosemite(El Capitan,Sierraも) で古い therubyracer -v 0.10.2 をインストールする

Last updated at Posted at 2015-09-04

参考

osx のバージョンと v8 はバージョンが合っていないと色々エラーになる。
参考

しかし古い therubyracer が使いたいので、下記の手順の通り、apple-gcc42 を入れて、v8 を、コンパイルしなおしたら、古いtherubyracer を入れられる。
追記:2016-11-14 El Capitan/Sierrar でも同じ手順でできました。

brew tap homebrew/dupes
brew install apple-gcc42
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
brew uninstall v8
gem uninstall libv8
rbenv rehash
gem install therubyracer -v '0.10.2'

参考

bundle install 時コケるのを直す

Installing therubyracer 0.10.2 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/ookubo/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for main() in -lobjc... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling rr.cpp
clang: warning: argument unused during compilation: '-rdynamic'
rr.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling v8.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_array.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_callbacks.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_context.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_date.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_debug.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_exception.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_exception.cpp:10:16: warning: unused variable 'stack' [-Wunused-variable]
  static void* stack[20];
               ^
1 warning generated.
compiling v8_external.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_external.cpp:10:9: warning: unused variable 'references' [-Wunused-variable]
  VALUE references;
        ^
1 warning generated.
compiling v8_function.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_handle.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_locker.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_locker.cpp:45:5: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
v8_locker.cpp:85:5: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
2 warnings generated.
compiling v8_message.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_object.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_object.cpp:77:19: warning: unused variable 'proto' [-Wunused-variable]
    Handle<Value> proto(rr_rb2v8(prototype));
                  ^
1 warning generated.
compiling v8_script.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_string.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_template.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_try_catch.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_v8.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_value.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_value.cpp:100:9: warning: unused function 'ToInt32' [-Wunused-function]
  VALUE ToInt32(VALUE self) {
        ^
1 warning generated.
compiling v8_weakref.cpp
clang: warning: argument unused during compilation: '-rdynamic'
linking shared-object v8.bundle
clang: error: no such file or directory: '/Users/ookubo/rails_sample/vendor/bundle/ruby/2.1.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'
make: *** [v8.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ookubo/rails_sample/vendor/bundle/ruby/2.1.0/gems/therubyracer-0.10.2 for inspection.
Results logged to /Users/ookubo/rails_sample/vendor/bundle/ruby/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/therubyracer-0.10.2/gem_make.out

上記のようなエラーが出るので、
シンボリックリンクが無く bundle でエラーになるので、下記のようにリンクを貼る
$RAILS_ROOT と rbenv のパスは、各自の環境に応じて変更する

rbenv を使ってる場合

export RAILS_ROOT=自分のRailsルート
ln -s ~/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a $RAILS_ROOT/vendor/bundle/ruby/2.1.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a

anyenv 経由で rbenv を使ってる場合

export RAILS_ROOT=自分のRailsルート
ln -s ~/.anyenv/envs/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a $RAILS_ROOT/vendor/bundle/ruby/2.1.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a
3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?