我也有同样的问题:
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
系统信息:
[root@server ~]# 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
[root@server ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@server ~]# 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
我懂了:
[root@server ~]# 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。为了解决这个问题,我们需要从源代码安装 ruby:
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 source /etc/profile.d/rvm.sh 感谢 rvm !!!
记住!要从 RVM 安装 rails,您需要在安装 ruby-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