Archive for November, 2009

MySQL Gem on 64-bit Snow Leopard

Posted on November 28th, 2009 in Web Development | No Comments »

Finally took some time to move a small rails application from my old Macbook Pro to my Macbook Pro running Snow Leopard and MAMP. Setting up autotest which should have just been a few commands ended up being a battle getting the MySQL gem set up correctly.

Autotest setup

What should have been quick and simple…

sudo gem install ZenTest
gem install autotest-rails

Make a file named .autotest in the root directory of the application and add:

require "autotest/growl"

Ended up being…

1) Update the system first.:

sudo gem update --system

Error:

!!! The bundled mysql.rb driver has been removed from Rails 
2.2. Please install the mysql gem and try again: gem install 
mysql.

From this point the battle starts. I have recompiled the MySQL gem many times trying to get it working. Excerpts of a few errors:

Enclosing class/module 'mXML' for class XPointer not known
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
 
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
ERROR:  Error installing rubynode:
ERROR: Failed to build gem native extension.
 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
==================== ERROR =====================
Please set RUBY_SOURCE_DIR to the source path of ruby 1.8.7 (2008-08-11)!
================================================
uninitialized constant MysqlCompat::MysqlRes

The solution…

Finally got it working following the steps in this article. One gotcha of this article – since we are installing on a 64 bit operating system the last step needs to be installed with the -arch x86_64 flag, not -arch i386.

First download the MAMP source here, then:

unzip MAMP_1.7.2_src.zip
cd MAMP_1.7.2_src
tar -xzvf mysql-5.0.41.tar.gz
cd mysql-5.0.41 
./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library
make -j2
cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql 
mkdir /Applications/MAMP/Library/include
cp -R include /Applications/MAMP/Library/include/mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

Git – Ignore already checked in file/directory

Posted on November 14th, 2009 in Web Development | No Comments »

Original Source: stackoverflow.com

This command will cause git to untrack your directory and all files under it without actually deleting them:

git rm -r --cached <your directory>

The -r option causes the removal of all files under your directory.
The –cached option causes the files to only be removed from git’s index, not your working copy. By default git rm would delete .