I had to install, fresh, Ruby On Rails this evening. I ran into a little road bump when issuing sudo gem install mysql on OS X.
The script prints out to the terminal:
! sudo gem install mysql
Select which gem to install for your platform (i686-darwin8.10.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. mysql 2.5.1 (ruby)
6. Cancel installation
I picked 4 as a 1 & 2 are for Windows and option 3 installs the latest greatest Ruby. I just needed Ruby 1.8 support and therefore, I picked 4 but 5 could work, too.
My result was a failure:
! sudo gem install mysql
Select which gem to install for your platform (i686-darwin8.10.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. mysql 2.5.1 (ruby)
6. Cancel installation
> 4
Building native extensions. This could take a while...
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6/gem_make.out
Solution was quickly GooGleD with few wrong answers, but
Hivelogic, as usual rox!! A simple parameter was forgotten and not well documented. So now here it is for future reference, and in stickies for my lightening fast access. Stickies is still a great app.
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
<Big:jes> 0 [03-28 00:10] ~/dev/vino (.007 Mb)
! sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Select which gem to install for your platform (i686-darwin8.10.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. mysql 2.5.1 (ruby)
6. Cancel installation
> 4
Building native extensions. This could take a while...
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'
mysql.c:637: error: 'res_free' undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
make: *** [mysql.o] Error 1
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'
mysql.c:637: error: 'res_free' undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
make: *** [mysql.o] Error 1
ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()... yes
checking for mysql.h... yes
creating Makefile
make
gcc -fno-common -g -O2 -pipe -fno-common -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.10.1 -I/usr/local/lib/ruby/1.8/i686-darwin8.10.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -Os -arch i386 -fno-common -c mysql.c
make install
mkdir -p /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6/lib
gcc -fno-common -g -O2 -pipe -fno-common -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.10.1 -I/usr/local/lib/ruby/1.8/i686-darwin8.10.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -Os -arch i386 -fno-common -c mysql.c
make clean
Successfully installed mysql-2.6
There you go!
tags: ruby rails ror gem mysql
links: digg this del.icio.us technorati reddit