Fix for FreeTDS, Ruby ODBC on Max OS X Leopard
Friday, November 30th, 2007If you’re like me, you have been happily developing your ruby projects connecting to an RDMS through unixodbc and rubyodbc in Mac OS X Tiger only to find it break in OS X Leopard without good reason. Well, after agonizing since October 29th I’ve compiled the necessary steps to get you back up and happily connecting your RoR projects to RDMS’ through ODBC in Leopard.
Steps successfully used on clean install of Leopard.
1. Download the latest stable release of freetds.
2. Extract freetds tgz file within Downloads
3. Open terminal and cd to Downloads/freetds-0.** folder
4. run “./configure”
5. run “cp /usr/bin/glibtool libtool” <----Important!
6. run "sudo make"
7. run "sudo make install"
8. Next create an ODBC directory in your /Library folder
9. You'll need to create odbc.ini and odbcinst.ini files if you don't have any already.
Should look like this
/Library/ODBC/odbcinst.ini:
[ODBC Drivers]
JDBC = Installed[JDBC]
Description = Sybase JDBC Server
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
/Library/ODBC/odbc.ini:[ODBC Data Sources]
MySQLServer = JDBC[MyDSN]
Driver = /usr/local/lib/libtdsodbc.so
Description = Description of this database connection
Trace = yes
TraceFile = /tmp/odbc.log
Servername = MySQLServer
Database = YOUR_ACUTAL_DB_NAME
To test:
% iodbctest “dsn=MyDSN;uid=USERNAME;pwd=PASSWORD”
You should be able to run SQL commands at this point.
Now you need to install a couple of Ruby libraries: ruby-dbi and ruby-odbc.
10. Download ruby-odbc version 0.9995 from http://www.ch-werner.de/rubyodbc
11. Extrac tar.gz file and cd to “ruby-odbc-0.999X”
12. run “ruby extconf.rb”
13. run “sudo make”
14. run “sudo make install”
15. Download http://rubyforge.org/frs/download.php/655/ruby-dbi-all-0.0.23.tar.gz
16. Extract ruby-dbi-all-0.0.23.tar.gz to downloads
17. cd ruby-dbi-all
17. run “ruby setup.rb config –with=dbi,dbd_odbc”
18. run “ruby setup.rb setup”
19. run “sudo ruby setup.rb install”
Congratulations! You should now be happily connect to ODBC connections, namely MSSQL, through ruby again in Apple’s latest OS.
***If you get any errors after freetds install try clearing our *odbc* and *tds* files inside /usr/local/lib directory. Happened to me once in about 5 installs. Likely a missed error and missed sudo command on my part.