I have the same problem:
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
System info:
[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]
After running commands:
yum install ruby-rdoc ruby-devel -y
gem update
gem update --system
I see:
[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.
And i think that CentOS 6.4 at default repos does not support rails.
To solve problem, we need to install ruby from sources:
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
We don't need to remove default ruby-1.8.x
Just exec source /etc/profile.d/rvm.sh after rvm installed
Thanks to rvm!!!
Remember! To install rails from RVM, you need after installation ruby-1.9.3 run this command:
gem update --system 1.8.25
We did this to avoid error:
/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