2014-01-19 48 views
0

我跟着線程here上的說明,但我還是有以下錯誤信息:無法構建本地寶石擴展 - 配合安裝

Ayman$ rails -v 
Rails is not currently installed on this system. To get the latest version, simply type: 

$ sudo gem install rails 

You can then rerun your "rails" command. 
Ayman$ gem install rails 
Building native extensions. This could take a while... 
ERROR: Error installing rails: 
ERROR: Failed to build gem native extension. 

/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0' 
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:817:in `try_run' 
from extconf.rb:26:in `<main>' 


Gem files will remain installed in /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic-1.1.14 for inspection. 
Results logged to /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic-1.1.14/ext/gem_make.out 

Ayman$ 

我對寶石的最新版本,運行紅寶石2.0.0 ,和Mac 10.8。

任何線索我做錯了什麼?

更新

所以我每次安裝的Xcode命令行工具以下,現在還在recieving以下錯誤信息:

Ayman$ sudo gem install rails 
Building native extensions. This could take a while... 
ERROR: Error installing rails: 
ERROR: Failed to build gem native extension. 

/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/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/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:519:in  `try_link0' 
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:817:in `try_run' 
from extconf.rb:26:in `<main>' 


Gem files will remain installed in /Users/Ayman/.rvm/rubies/ruby-2.0.0- p353/lib/ruby/gems/2.0.0/gems/atomic-1.1.14 for inspection. 
Results logged to /Users/Ayman/.rvm/rubies/ruby-2.0.0- p353/lib/ruby/gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out 

艾曼$

更新兩個

按照以下步驟進行下面的rbenv安裝NG:

Ayman$ brew update 
Updated Homebrew from 8e60080c to e7a77f80. 
==> Updated Formulae 
reposurgeon 
Ayman$ brew install rbenv ruby-build 
Warning: rbenv-0.4.0 already installed 
Warning: ruby-build-20140110.1 already installed 
Ayman$ echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile 
Ayman$ ~/.bash_profile 
-bash: /Users/Ayman/.bash_profile: Permission denied 
Ayman$ rbenv install 2.1.0 
Downloading ruby-2.1.0.tar.gz... 
-> http://dqw8nmjcqpjn7.cloudfront.net/9e6386d53f5200a3e7069107405b93f7 
Installing ruby-2.1.0... 
Installed ruby-2.1.0 to /Users/Ayman/.rbenv/versions/2.1.0 

Ayman$ rbenv rehash 
Ayman$ rbenv global 2.1.0 
Ayman$ gem install rails bundler --no-ri --no-rdoc 
ERROR: While executing gem ... (Errno::EACCES) 
Permission denied - /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic- 1.1.14/test/test_atomic.rb 
+0

是否安裝了Xcode命令行工具? – revolver

+0

是的,我已經安裝了Xcode – aalab002

+0

http://stackoverflow.com/questions/9353444/how-to-use-install-gcc-on-mac-os-x-10-8-xcode-4-4應該可以幫到你。 – mudasobwa

回答

3

我解決了這個問題。

原來我使用的是過時的寶石版本。

一旦我將我的寶石升級到最新版本,它工作正常。

謝謝大家!

1

嘗試rvmsudo使用您的RVM和具有root權限,也許是這樣的:

rvmsudo gem install rails 

編輯

我的意思是 'rvmsudo',而不是 'sudorvm'。對不起,我正在打電話。

+0

'Ayman $ sudorvm gem install rails -bash:sudorvm:command not found' – aalab002

+0

剛剛用'rvmsudo'而不是'sudorvm'嘗試過,並且工作並提示輸入密碼並開始初始化,但之後返回相同的錯誤消息。 – aalab002

+0

我只是試了一遍,現在我得到了'錯誤:執行gem時...(Gem :: RemoteFetcher :: UnknownHostError) 沒有這樣的名字(http://api.rubygems.org/quick/Marshal.4.8/minitest -4.7。5.gemspec.rz)' – aalab002

1

總是有rbenv您可以跳過所有sudo和權限的麻煩。用戶本地的所有東西。 Why rbenv

brew update 
brew install rbenv ruby-build 

# if you dont have the init in your profile run the following: 
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile 
source ~/.bash_profile 

# install a ruby 
rbenv install 2.1.0 
# you need to rehash after installing a ruby version or a global gem 
rbenv rehash 
# this will set 2.1.0 as your default ruby version in shell 
rbenv global 2.1.0 

# now try installing rails 
gem install rails bundler --no-ri --no-rdoc 
rbenv rehash 
+0

我下載了rbenv,但似乎無法找到安裝rails的命令。所有文檔都告訴我只需運行'gem install rails',並返回相同的錯誤消息。 – aalab002

+0

當我嘗試'rbenv安裝rails'它告訴我'沒找到紅寶石構建定義:rails'所以我列出了可用的版本: '$艾曼安裝rbenv --list 可用版本:1.8.6 -P383 1.8 0.6-P420 1.8.7-P249 1.8.7-P302 1.8.7-P334 1.8.7-P352 1.8.7-P357 1.8.7-P358 1.8.7-P370 1.8.7 -p371 1.8.7-P374 1.8.7-P375 1.9.1-P378 1.9.1-P430 1.9.2-P0 1.9.2-P180 1.9.2-P290 1.9.2-P318 1.9.2-P320 1.9.2-P326 1.9.3-dev的 1.9.3-P0 1.9.3-P125 1.9.3-P194 1.9 0.3-p286' – aalab002

+0

'1.9.3-P327 1.9.3-P362 1.9.3-P374 1.9.3-P385 1.9.3-P392 1.9.3-429頁 1.9.3-P448 1.9 0.3-P484 1.9.3-preview1 1.9.3-RC1 2.0.0-dev的 2.0.0-P0 2.0.0-P195 2.0.0-P247 2.0.0-P353 2.0.0-preview1 2.0.0-preview2 2.0.0-RC1 2.0.0-RC2 2.1.0 2.1.0-dev的 2.1.0-preview1 2.1.0- preview2 2.1.0-RC1 2.2.0-dev' – aalab002

相關問題