Rails MySQL and Leopard
UPDATE:
I didn’t know about the ARCHFLAGS environment variable, this is a less intrusive way (thanks to Sebastian for pointing this out):
sudo su - ARCHFLAGS='-arch i386' gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(sudo su – asks you for your normal password not the root password)
I’m using the stock ruby environment on Leopard and the MySQL Package from http://www.mysql.com.
Unfortunately installing the mysql driver as a gem doesn’t work out of the box and the default mysql driver that comes with rails seems to be quite buggy.
To get it working we have to remove all occurrences of “-arch ppc” in rbconfig.rb, otherwise it tries to compile the mysql driver for the powerpc plattform as well, what we don’t want (assuming you have an Intel Mac, otherwise remove “-arch i386″).
We also have to tell the driver where to find the the mysql libs, includes and so on. We can do this by specifying where the path the mysql_config command.
cd /usr/lib/ruby/1.8/universal-darwin9.0/ sudo mv rbconfig.rb rbconfig.rb.orig sudo sed "s/-arch ppc//g" rbconfig.rb.orig > rbconfig.rb sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(if you use a PPC Mac replace ppc with i386 on line 2)
Thanks Philipp this worked great. I had to add a couple of lines to get it to work on my machine see below.
cd /usr/lib/ruby/1.8/universal-darwin9.0/
sudo mv rbconfig.rb rbconfig.rb.orig
sudo chmod 777 /usr/lib/ruby/1.8/universal-darwin9.0/
sudo sed “s/-arch ppc//g” rbconfig.rb.orig > rbconfig.rb
sudo chmod 755 /usr/lib/ruby/1.8/universal-darwin9.0/
sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
I came up with a “less intrusive” solution:
http://www.notsostupid.com/blog/2007/10/25/ruby-leopard-and-gems/
It boils down to
sudo bash -c “ARCHFLAGS=’-arch i386′ gem install mysql …”
Hi Philipp, tried to use your solution but got the following error. I’m on a Leopard clean install.
———————-
Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
ruby extconf.rb install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
extconf.rb:1: command not found: /usr/local/mysql/bin/mysql_config –cflags
*** 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.
(…)
———————-
Ideas? Thank you so much!
Thanks so much Philipp. Your post came as a savior. Sebastian’s ARCHFLAGS fixed the issue for me as well. I can now rake to pleasure
Thanks again!
Thanks Philipp!
I used your trick then copied files as recommended on:
http://bugs.mysql.com/bug.php?id=29580
cd /usr/local/mysql/lib
mkdir mysql
cp libmysqlclient.15.dylib mysql/libmysqlclient.15.dylib
[...] After a bit of googling, it turns out you need to give a bit more information for this gem: [...]
This is a very interesting post, I was looking for this information. Just so you know I found your site when I was doing research for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think.
What a blog! I in reality like how everything is well written. I am asking myself how I might be contacted whenever there’s something new on here. I have bookmarked your site thank you!
I found your weblog on google and check several of the early posts. Preserve up the excellent operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading through additional from you later on!…
Searching for homes? Visit Kirkland Homes For Sale…
Thanks, I’ve been searching for information about this subject matter for ages and yours is the best I’ve found so far.
I have really learned new things via your blog site. One other thing I would like to say is newer laptop or computer operating systems usually allow more memory to be played with, but they as well demand more memory simply to run. If one’s computer cannot handle extra memory along with the newest program requires that ram increase, it may be the time to buy a new Laptop or computer. Thanks