2017-05-16 91 views
0

創建.ruby-version文件,1.8.7後,在該文件是提供了以下錯誤同一目錄下運行rbenv installrbenv無法在MacOS X塞拉利昂安裝Ruby 1.8.7

ERROR: This package must be compiled with GCC, but ruby-build couldn't find a suitable gcc executable on your system. Please install GCC and try again.

DETAILS: Apple no longer includes the official GCC compiler with Xcode as of version 4.2. Instead, the gcc executable is a symlink to llvm-gcc , a modified version of GCC which outputs LLVM bytecode.

For most programs the llvm-gcc compiler works fine. However, versions of Ruby older than 1.9.3-p125 are incompatible with llvm-gcc . To build older versions of Ruby you must have the official GCC compiler installed on your system.

TO FIX THE PROBLEM: Install Homebrew's apple-gcc42 package with this command: brew tap homebrew/dupes ; brew install apple-gcc42

You will need to install the official GCC compiler to build older versions of Ruby even if you have installed Apple's Command Line Tools for Xcode package. The Command Line Tools for Xcode package only includes llvm-gcc .

BUILD FAILED (OS X 10.12.4 using ruby-build 20170405-2-g3b15693)

然後運行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. Error: An unsatisfied requirement failed this build.

卡住試圖在MacOS X Sierra上通過rbenv安裝ruby 1.8.7。有想法該怎麼解決這個嗎?

+1

究竟什麼是你的問題? –

+2

您是否將答案作爲問題的一部分發布?(將其轉換爲下面的答案) –

+0

謝謝Holger和Tom的評論。編輯該問題以澄清併發布解決方案作爲答案。 –

回答

2

以前的答案看起來不錯,但一些更新它:

您必須添加以下代碼也不行762後(因爲因版本線必須是不同的)。 您必須插入之後:

require_gcc() { 
    local gcc="$(locate_gcc || true)" 

這些線(對我來說是784線)

所以完全教程:

找到了解決辦法在這裏:http://xibbar.hatenablog.com

http://xibbar.hatenablog.com/entry/2017/04/28/112813

通過Google Transla運行後德,得到了這一點:

  • 查找ruby-buildwhich ruby-build
  • 編輯它(對我來說):vim /usr/local/bin/ruby-build
  • 找到的這些行:

    require_gcc(){ 當地GCC = 「$(locate_gcc ||真)」

  • 添加以下代碼後:

    local osx_version="$(osx_version)" 
    if [ $osx_version = "1012" ]; then 
    return 0 
    fi 
    
  • 運行:

    CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=`brew --prefix openssl`" RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 1.8.7-p374 
    

希望這是對他人有用

1

發現這裏的解決方案:http://xibbar.hatenablog.com

通過谷歌翻譯它運行後,得到了這一點:

  • 查找ruby-buildwhich ruby-build
  • 編輯它(對我來說):vim /usr/local/bin/ruby-build
  • 在第762行之後添加以下代碼:

    local osx_version="$(osx_version)" 
    if [ $osx_version = "1012" ]; then 
    return 0 
    fi 
    
  • 運行:

    CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=`brew --prefix openssl`" RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 1.8.7-p374 
    

希望這是有用的人。

相關問題