2013-08-01 237 views
4

新手在這裏。我在網站上搜索了其他類似的問題,但仍無法解決問題。我已經安裝了Ruby 2.0.0和2.0.3 RubyGem,但是當我試圖安裝Rails 4.0.0我:安裝Rails時出現「extconf.rb failed」消息

Building native extensions. This could take a while... 
ERROR: Error installing rails: 
    ERROR: Failed to build gem native extension. 
    /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of necessary 
libraries and/or headers. Check the mkmf.log file for more details. You may 
need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/bin/ruby 
    --with-atomic_reference-dir 
    --without-atomic_reference-dir 
    --with-atomic_reference-include 
    --without-atomic_reference-include=${atomic_reference-dir}/include 
    --with-atomic_reference-lib 
    --without-atomic_reference-lib=${atomic_reference-dir}/ 
/Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0' 
    from /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/mkmf.rb:814:in `try_run' 
    from extconf.rb:22:in `<main>' 


Gem files will remain installed in /Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0/gems/atomic-1.1.10 for inspection. 
Results logged to /Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0/gems/atomic-1.1.10/ext/gem_make.out 

我試圖通過

gem install rails --version 4.0.0 

我安裝Rails我不確定設置是否有問題,或者是否還需要安裝。在此先感謝您的幫助。

+0

你有沒有在這個(可能是linux)系統上安裝的標準開發工具?就像c編譯器一樣,你在運行什麼linux? – Daiku

+1

您發佈的錯誤消息部分沒有提供信息,而不是此帖的上一部分錯誤消息 –

+1

**「您必須先安裝開發工具。」** – tadman

回答

1

看來你使用的是OSX。

如果由於缺少編譯器(「您必須先安裝開發工具」)而無法編譯某些擴展,則會發生此錯誤。打開App Store,下載XCode,安裝完成後點擊菜單上的「XCode」,進入首選項 - >下載 - >組件,然後下載「命令行工具」。

+0

我以爲這是我需要的,但是我從Xcode下載命令行工具並安裝它之後,我仍然收到相同的錯誤消息。也許這不是編譯器的問題?謝謝。 – mlo

+0

嘿,在命令行輸入「哪個gcc」後會發生什麼? – agarie

+0

它返回 '/ usr/bin/gcc' – mlo