Installing mysql gem on RHEL 5.2 Tikanga. This actually works.

Posted by nick.stielau on April 27, 2009

Ok, lets start at the beginning. Nice, freshish RHEL 5.2 box. Try to install mysql gem...

CODE:
  1. [nick@Dev1 ~]$ sudo gem install mysql
  2. Password:
  3. Building native extensions.  This could take a while...
  4. ERROR:  Error installing mysql:
  5.     ERROR: Failed to build gem native extension.
  6.  
  7. /usr/bin/ruby extconf.rb
  8. checking for mysql_query() in -lmysqlclient... no
  9. checking for main() in -lm... no
  10. checking for mysql_query() in -lmysqlclient... no
  11. checking for main() in -lz... no
  12. checking for mysql_query() in -lmysqlclient... no
  13. checking for main() in -lsocket... no
  14. checking for mysql_query() in -lmysqlclient... no
  15. checking for main() in -lnsl... no
  16. checking for mysql_query() in -lmysqlclient... no
  17. *** extconf.rb failed ***
  18. Could not create Makefile due to some reason, probably lack of
  19. necessary libraries and/or headers.  Check the mkmf.log file for more
  20. details.  You may need configuration options.
  21.  
  22. Provided configuration options:
  23.     --with-opt-dir
  24.     --without-opt-dir
  25.     --with-opt-include
  26.     --without-opt-include=${opt-dir}/include
  27.     --with-opt-lib
  28.     --without-opt-lib=${opt-dir}/lib
  29.     --with-make-prog
  30.     --without-make-prog
  31.     --srcdir=.
  32.     --curdir
  33.     --ruby=/usr/bin/ruby
  34.     --with-mysql-config
  35.     --without-mysql-config
  36.     --with-mysql-dir
  37.     --without-mysql-dir
  38.     --with-mysql-include
  39.     --without-mysql-include=${mysql-dir}/include
  40.     --with-mysql-lib
  41.     --without-mysql-lib=${mysql-dir}/lib
  42.     --with-mysqlclientlib
  43.     --without-mysqlclientlib
  44.     --with-mlib
  45.     --without-mlib
  46.     --with-mysqlclientlib
  47.     --without-mysqlclientlib
  48.     --with-zlib
  49.     --without-zlib
  50.     --with-mysqlclientlib
  51.     --without-mysqlclientlib
  52.     --with-socketlib
  53.     --without-socketlib
  54.     --with-mysqlclientlib
  55.     --without-mysqlclientlib
  56.     --with-nsllib
  57.     --without-nsllib
  58.     --with-mysqlclientlib
  59.     --without-mysqlclientlib
  60.  
  61.  
  62. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
  63. Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Yikes! Look familiar? Bummer. First step, brute force install everything I could think might be missing

CODE:
  1. sudo yum install gcc mysql-server mysql-devel ruby ruby-devel

Turns out, the gcc was having some issues:

CODE:
  1. [nick@Dev1 mysql-2.7]$ sudo yum install gcc
  2. Loading "rhnplugin" plugin
  3. Loading "security" plugin
  4. intensive-rhel-i386-serve 100% |=========================| 1.2 kB    00:00     
  5. rackspace-int-rhel-i386-s 100% |=========================| 1.2 kB    00:00     
  6. Excluding Packages in global exclude list
  7. Finished
  8. Setting up Install Process
  9. Parsing package install arguments
  10. Resolving Dependencies
  11. --> Running transaction check
  12. ---> Package gcc.i386 0:4.1.2-42.el5 set to be updated
  13. --> Processing Dependency: libgomp = 4.1.2-42.el5 for package: gcc
  14. --> Processing Dependency: cpp = 4.1.2-42.el5 for package: gcc
  15. --> Processing Dependency: libgomp.so.1 for package: gcc
  16. --> Processing Dependency: glibc-devel>= 2.2.90-12 for package: gcc
  17. --> Running transaction check
  18. ---> Package cpp.i386 0:4.1.2-42.el5 set to be updated
  19. ---> Package glibc-devel.i386 0:2.5-24.el5_2.2 set to be updated
  20. --> Processing Dependency: glibc-headers = 2.5-24.el5_2.2 for package: glibc-devel
  21. --> Processing Dependency: glibc-headers for package: glibc-devel
  22. ---> Package libgomp.i386 0:4.1.2-42.el5 set to be updated
  23. --> Running transaction check
  24. ---> Package glibc-headers.i386 0:2.5-24.el5_2.2 set to be updated
  25. --> Processing Dependency: kernel-headers>= 2.2.1 for package: glibc-headers
  26. --> Processing Dependency: kernel-headers for package: glibc-headers
  27. --> Finished Dependency Resolution
  28. Error: Missing Dependency: kernel-headers is needed by package glibc-headers
  29. Error: Missing Dependency: kernel-headers>= 2.2.1 is needed by package glibc-headers

Googling around a little, I found this helpful page which indicated that the default RHEL yum configuration excludes updates from the kernel. That is probably good practice in general, but right now it is preventing us from doing what "needs to be done."

Looking at my /etc/yum.conf file, indeed the kernal was excepted from updates:

CODE:
  1. [nick@Dev1 ~]$ cat /etc/yum.conf
  2. [main]
  3. cachedir=/var/cache/yum
  4. keepcache=0
  5. debuglevel=2
  6. logfile=/var/log/yum.log
  7. distroverpkg=redhat-release
  8. tolerant=1
  9. exactarch=1
  10. obsoletes=1
  11. gpgcheck=1
  12. plugins=1
  13.  
  14. # Note: yum-RHN-plugin doesn't honor this.
  15. metadata_expire=1h
  16. # Default.
  17. # installonly_limit = 3
  18. # PUT YOUR REPOS HERE OR IN separate files named file.repo
  19. # in /etc/yum.repos.d
  20. exclude=kernel*

So I commented out that line, yum installed gcc, and then off to the races. My googling also noted that passing the --with-mysql-config saves you some trouble, essentially letting it configure itself.

CODE:
  1. [nick@Dev1 ~]$ sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
  2. Building native extensions.  This could take a while...
  3. Successfully installed mysql-2.7
  4. 1 gem installed

Just in case, you might want to uncomment the kernal extension from your /etc/yum.conf file!