Monday, July 26, 2010

Commands...I always forget


  • Locating a file: sudo find / -name my-large.cnf -print
  • Disk usage: df -kh

MySQL gem installation problem (Mac OS X - 10.5.8, RVM, Ruby 1.9.1)

As mentioned in my previous post, I have been working with RVM on Mac OS X. I have had real troubles installing MySQL gem with ruby-1.9.1p378 on RVM. I tried different things:


  • Removed RVM setup using rvm implode

  • env ARCHFLAGS="-arch x86_64" gem install mysql --verbose -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

  • Re-installed MySQL through DMG archive

  • Tried building MySQL gem on my machine



Every single time I was let down. I got the same error every single time:



ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/backward -I/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -O2 -g -Wall -Wno-parentheses -fno-common -pipe -fno-common -o mysql.o -c mysql.c
In file included from /Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby.h:32,
from mysql.c:5:
/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/ruby.h: In function 'INT2NUM':
/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/ruby.h: In function 'UINT2NUM':
/Users/BLAH/.rvm/rubies/ruby-1.9.1-p378/include/ruby-1.9.1/ruby/ruby.h:472: warning: comparison is always true due to limited range of data type
mysql.c: In function 'escape_string':
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function 'real_escape_string':
mysql.c:434: error: lvalue required as left operand of assignment
mysql.c:434: error: lvalue required as left operand of assignment
make: *** [mysql.o] Error 1



Finally, I consulted a colleague (David) at work. He suggested me to install MySQL via ports. Guess what???!!! He was spot on....!!

SOLUTION:
All I had to do was:


  • Install MySQL via ports

  • env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5