2013-10-08 92 views
2

接收下面的錯誤,而安裝程序包,並使用我錯誤安裝任何寶石包:::創業板安裝導軌或創業板安裝瀟灑

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

    /usr/bin/ruby extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib64/ruby/ruby.h 


Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/atomic-1.1.14 for inspection. 
Results logged to /usr/lib64/ruby/gems/1.8/gems/atomic-1.1.14/ext/gem_make.out 


# gem -v 
2.1.5 
# ruby -v 
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] 

誰能請在解決這個問題的幫助,因爲我已經試圖改變導出PATH = $ PATH:/ ruby​​路徑,並嘗試安裝ruby-dev,但無法在rubygems.com上找到它,或者通過gem安裝ruby-dev或ruby-devel。

+0

什麼平臺是你嗎?我猜測一些Linux的味道?你有沒有嘗試過使用[rvm](https://rvm.io)? Ruby 1.8.7相當古老,RubyGems 2.1.5相當新穎,你怎麼最終得到這種組合? –

+0

Suse linux在SLES11SP2上,所以我們有紅寶石1.8.7,因爲我安裝了rubygem,所以它在2.1.5上。 – Sunnx

+0

使用一些Ruby版本管理器,如[RVM](http://rvm.io/)或[rbenv]( http://rbenv.org/)(我個人的選擇)。如果你不想使用任何這些(這是個壞主意),那麼你需要安裝某種'dev'版本的Ruby,它將提供本地Ruby擴展所需的頭文件。 – Hauleth

回答

3

我有同樣的問題:

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

/usr/bin/ruby extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h 


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/atomic-1.1.14 for inspection. 
Results logged to /usr/lib/ruby/gems/1.8/gems/atomic-1.1.14/ext/gem_make.out 

系統信息:

[[email protected] ~]# uname -a 
    Linux server.com 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 
    [[email protected] ~]# cat /etc/redhat-release 
    CentOS release 6.4 (Final) 
    [[email protected] ~]# ruby -v 
    ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] 

運行命令後:

yum install ruby-rdoc ruby-devel -y 
gem update 
gem update --system 

我看到:

[[email protected] ~]# gem install rails 
Building native extensions. This could take a while... 
Successfully installed atomic-1.1.14 
Fetching: thread_safe-0.1.3.gem (100%) 
Successfully installed thread_safe-0.1.3 
Fetching: activesupport-4.0.0.gem (100%) 
ERROR: Error installing rails: 
    activesupport requires Ruby version >= 1.9.3. 

我認爲在默認回購的CentOS 6.4不支持rails。 爲了解決問題,我們需要從源代碼安裝紅寶石:

curl -L get.rvm.io | bash -s stable 
source /etc/profile.d/rvm.sh 
rvm requirements 
rvm install 1.9.3 
rvm use 1.9.3 --default 
rvm rubygems current 

我們並不需要刪除默認的Ruby-1.8.x的安裝RVM後 只是EXEC源/etc/profile.d/rvm.sh 感謝rvm!

請記住!若要從RVM安裝護欄,需要安裝後的紅寶石1.9.3運行此命令:

gem update --system 1.8.25 

我們這樣做是爲了避免錯誤:

/script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) 
    from ./script/../config/boot.rb:60:in `load_initializer' 
    from ./script/../config/boot.rb:44:in `run' 
    from ./script/../config/boot.rb:17:in `boot!' 
    from ./script/../config/boot.rb:123 
    from script/server:2:in `require' 
    from script/server:2 
相關問題