难以在Mac OSX 10.12.6 Sierra上安装therubyracer 0.10.2和apple-gcc42

时间:2017-09-07 19:51:48

标签: ruby-on-rails macos v8 therubyracer libv8

this similar question的答案并不能解决我的问题。以下是该问题的答案:

  

如果你决定使用更新的therubyracer宝石版,你就不会   更长时间有这个问题

     

否则:

brew tap homebrew/dupes # Thanks Tom
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

gem install therubyracer -v '0.10.2' # specify version

我遇到这个问题的问题是apple-gcc42。当我运行这一行时:

brew install apple-gcc42

我收到以下错误:

apple-gcc42: This formula either does not compile or function as expected on macOS
versions newer than Mavericks due to an upstream incompatibility.

如果我忽略该错误并尝试gem install therubyracer -v '0.10.2',我会得到这个:

current directory: /Users/wylliam/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.2/ext/v8
/Users/wylliam/.rbenv/versions/1.9.3-p551/bin/ruby -r ./siteconf20170907-76249-1po4ii1.rb extconf.rb
checking for main() in -lobjc... yes
creating Makefile

current directory: /Users/wylliam/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.2/ext/v8
make  clean

current directory: /Users/wylliam/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.2/ext/v8
make
compiling rr.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
compiling v8_array.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_callbacks.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_context.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_date.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_debug.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_exception.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
compiling v8_handle.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_locker.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
compiling v8_object.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
compiling v8_string.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_template.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_try_catch.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_v8.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
compiling v8_value.cpp
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
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' [-Wunused-command-line-argument]
linking shared-object v8.bundle
clang: error: no such file or directory: '/Users/wylliam/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'
make: *** [v8.bundle] Error 1

make failed, exit code 2

我尝试了许多其他解决方案,例如其他问题的答案,但大多数都依赖于apple-gcc42。

1 个答案:

答案 0 :(得分:0)

你为什么要卸载libv8?输出中的错误行:

error: no such file or directory: '/Users/wylliam/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'

听起来像缺少libv8。尝试安装吗?它似乎在寻找libv8-3.3.10.4,所以也许你必须指定版本?

附注:V8 3.3.10.4来自2011年,甚至不是3.3分支的最新补丁,因此几乎可以保证充满了以后发现并修复的错误,这可能与安全相关。不要在那里运行不受信任的代码!