2013-09-29 147 views
3

我下載了xcode,命令行工具,home brew,rvm和ruby,但是當我使用命令sudo gem install rails時,我收到一條錯誤消息。不知道要做什麼幫助會很好,我想在我的新Mac上安裝rails。在mac上失敗的gem install rails錯誤:無法構建gem原生擴展

ERROR: While executing gem ... (Errno::EACCES) 
    Permission denied - /Users/cheatermoves/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/test/test_atomic.rb 
marshalls-MacBook-Air:~ cheatermoves$ sudo gem install rails 
Building native extensions. This could take a while... 
ERROR: Error installing rails: 
    ERROR: Failed to build gem native extension. 

    /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/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 
    --without-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/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/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/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0' 
    from /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run' 
    from extconf.rb:26:in `<main>' 
+0

'gcc --version'的輸出是什麼? –

+0

配置:--prefix =/Applications/Xcode.app /目錄/ Developer/usr --with-gxx-include-dir =/usr/include/C++/4.2.1 Apple LLVM 5.0版(clang-500.2。 76)(基於LLVM 3.3svn) 目標:x86_64-apple-darwin12.5.0 線程模型:posix –

+0

我得到了同樣的錯誤... – christian

回答

0

你可能不希望被使用sudo與RVM ...嘗試只是:

gem install rails 
0
sudo gcc --version 

當你這樣做在Xcode接受用戶協議! (這對我來說是固定的。)

相關問題