Monday, November 14, 2011

OCI8 with Phusion Passenger/Rails 3.1 on Freebsd 8 ** UPDATED

This has been one of the most trying things I've done..  My employer uses a backend database of Oracle 9i, or the like.  I have to connect to it with Rails to simplify some queries, using oci8. 

Ruby 1.9.2 also.

Install the freebsd linux-oracle-instantclient-* ports
follow directions here: http://ruby-oci8.rubyforge.org/en/InstallForFullClient.html
(You will have to install both oracle ports)

Punch something that won't break your hand, but will be hard enough to relieve some anger

Use gems, NOT the ports collection for the gems..

gem install ruby-oci8 (Using the freebsd port fucks everything up)
gem install activerecord-oracle_enhanced-adapter

You will have to modify  /usr/local/lib/ruby/site_ruby/oci8.rb to make line 38 know where your .so file is.  replace site_ruby with your ruby install path.  I use site_ruby because of rvm (Another goddamn hassle to set up)

This got me up and running, but I am not sure if these steps are in order, or if I did anything else.  This was a fucking hassle and I  wouldn't recommend doing it.. but if you have to, and you get stuck, post a comment and I'll see if I can't help you figure out your problem

~Nic

ETA:

A ruby wrapper to set this bullshit is necessary as well:

#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/oracle8-client/lib
export TNS_ADMIN=/usr/local/oracle8-client/network/admin
export NLS_LANG=AMERICAN_AMERICA.UTF8
export ORACLE_HOME=/usr/local/oracle8-client
exec "/usr/local/bin/ruby" "$@"

ETA2:

This only works on fucking i386.  If you have to use OCI8 on FreeBSD, it's only going to work on i386.  I tried and tried, and no x64.

1 comment: