【问题标题】:Cannot install gem 'therubyracer' in OS X Mavericks无法在 OS X Mavericks 中安装 gem 'therubyracer'
【发布时间】:2013-11-10 22:09:17
【问题描述】:

我是 mac 新手,并尝试 bundle install 克隆的 rails 存储库。我在安装 libv8 gem 时遇到错误,谷歌搜索并找到了解决方案并做到了

brew install libv8
gem install libv8 -- --with-system-v8

接下来我被thresracer gem击中了,完整的痕迹如下

Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    /Users/anand/.rvm/rubies/ruby-2.0.0-p247/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
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[1]: *** [/Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a] Error 1
make: *** [x64.release] Error 2
/Users/anand/.rvm/gems/ruby-2.0.0-p247/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/anand/.rvm/gems/ruby-2.0.0-p247/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/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
    from /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/anand/.rvm/gems/ruby-2.0.0-p247/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/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
  LIBTOOL-STATIC /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a


Gem files will remain installed in /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/anand/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.16.14.3/ext/libv8/gem_make.out

我认为这是小牛队的问题。

【问题讨论】:

    标签: ruby-on-rails ruby osx-mavericks


    【解决方案1】:

    现在安装 v8 后尝试重新安装 ruby​​。

    rvm reinstall 2.0
    

    然后用gem install therubyracer安装rubyracer

    【讨论】:

    • 那行不通。我犯了同样的错误。不是GCC版本的问题吗..?
    【解决方案2】:

    你可能想试试我在这个问题中总结的内容:"gem install therubyracer -v '0.10.2'" on osx mavericks not installing

    brew install apple-gcc42
    
    sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc 
    sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++ 
    sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp
    
    brew uninstall v8 (only in case you installed it with brew)
    gem install libv8
    gem install therubyracer
    

    让我知道这是否有效!自从 Mavericks 推出以来,我一直在处理同样的问题 :)

    【讨论】:

    • 我试过了,但没有用。我已经回答了我自己的问题。很抱歉我不能给出一个非常明确的答案。
    • 可能添加 gcc42(你说 gcc47 但我猜你想说 gcc42,对吧?)成功了
    • libv8 gem(或至少 3.11.8.13)需要 GCC 4.4+。可能 gcc47 和更高版本的 therubyracer 修复了一些东西?
    【解决方案3】:

    抱歉,我不知道是什么解决了我的问题。我尝试了一切,它得到了修复。

    我使用 macports 安装 gcc47,而不是自制软件。(在我的慢速 512kbps 连接中安装花了将近 2 天时间)

    然后我将 therubyracer 的版本更改为'0.12.0'

    我不知道是哪个解决了我的问题。

    【讨论】:

    • 帮助某人解决了安装 therubyracer 的问题,并且从版本 0.11.4 更新到 0.12.0 也让我们解决了这个问题。我认为在尝试不同的解决方案时,我们可能在成功安装时一直在使用 apple-gcc-42。
    • 我不必安装 apple-gcc-42。迁移到 0.12.x 解决了我在编译时遇到的问题。
    【解决方案4】:

    当我从 OSX Mountain Lion 升级到 OSX Mavericks 时,我遇到了同样的问题。

    从 ruby​​-1.8.7-p354 升级到 ruby​​-1.8.7-375 对我有用。也许将您的 ruby​​ 2.0.0-p125 升级到 2.0.0-rc2(2.0 已经高于 p353)

    如果您使用的是 rbenv:

    rbenv install 2.0.0-rc2
    rbenv rehash
    rbenv shell 2
    
    bundle install
    

    【讨论】:

      【解决方案5】:
      gem uninstall libv8
      brew rm v8
      brew tap homebrew/dupes
      brew install apple-gcc42
      brew tap homebrew/versions
      brew install v8-315
      brew link --force v8-315
      gem install libv8 -- --with-system-v8
      gem install therubyracer
      

      感谢DeLaGuardo

      【讨论】:

      • brew tap homebrew/dupes 已弃用。
      猜你喜欢
      • 2014-06-17
      • 1970-01-01
      • 2012-03-25
      • 2014-08-15
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      • 2023-04-09
      • 2014-04-09
      相关资源
      最近更新 更多