I ran into a error when installing the first gem on a CentOS development server I was creating. The error states that the extconf.rb file could not the header files. Below I show the output of the error along with what was done to resolve the error.
Error Installing Ruby Gem:
- [root@dev rubygems-1.3.7]# gem install ruby-lsapi
- Building native extensions. This could take a while...
- ERROR: Error installing ruby-lsapi:
- ERROR: Failed to build gem native extension.
- /usr/bin/ruby extconf.rb
- can't find header files for ruby.
- Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ruby-lsapi-4.0 for inspection.
- Results logged to /usr/lib/ruby/gems/1.8/gems/ruby-lsapi-4.0/ext/lsapi/gem_make.out
As you can see above the gem failed to install. The reason is that I had not yet installed the ruby-devel package which is needed during the gem compilation process. After installing ruby-devel as shown below the gem installed without issue.
Install ruby-devel On CentOS Linux:
- [root@dev src]# yum install ruby-devel
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * addons: mirrors.xmission.com
- * base: centos.mirror.facebook.net
- * extras: mirrors.netdna.com
- * updates: mirrors.versaweb.com
- Setting up Install Process
- Resolving Dependencies
- --> Running transaction check
- ---> Package ruby-devel.i686 0:1.8.6.111-1 set to be updated
- --> Finished Dependency Resolution
- Dependencies Resolved
- ====================================================================================================================================
- Package Arch Version Repository Size
- ====================================================================================================================================
- Installing:
- ruby-devel i686 1.8.6.111-1 ruby 533 k
- Transaction Summary
- ====================================================================================================================================
- Install 1 Package(s)
- Upgrade 0 Package(s)
- Total download size: 533 k
- Is this ok [y/N]: y
- Downloading Packages:
- ruby-devel-1.8.6.111-1.i686.rpm | 533 kB 00:01
- Running rpm_check_debug
- Running Transaction Test
- Finished Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : ruby-devel 1/1
- Installed:
- ruby-devel.i686 0:1.8.6.111-1
- Complete!
- [root@dev src]#
After installing ruby-devel using the Yum Package Manager you can install the gem, which in this case was ruby-lsapi, without issue as shown in the below example output.
Install ruby-lsapi Gem Without extconf.rb Header Files Error:
- [root@dev rubygems-1.3.7]# gem install ruby-lsapi
- Building native extensions. This could take a while...
- Successfully installed ruby-lsapi-4.0
- 1 gem installed
- Installing ri documentation for ruby-lsapi-4.0...
- Installing RDoc documentation for ruby-lsapi-4.0...
- [root@dev rubygems-1.3.7]#
The ruby-lsapi gem is now installed and installing future gems should not run into issue either.
Add path to Your ruby.h in your $PATH
for example: export PATH=$PATH:/usr/src/ruby-xxxxxxxx
Hello Mareg,
Thanks for posting this tip.
Thanks.
alex