As of this writing the x64 version of the Oracle Instant Client do NOT work with OSX Lion. I got everything working like so:
Install Oracle Instant Client
Install the 32 bit version of the
Oracle Instant Client. Download and install the following packages to /usr/local/oracle/instantclient_10_2
- instantclient-basic-10.2.0.4.0-macosx-x86.zip
- instantclient-sqlplus-10.2.0.4.0-macosx-x86.zip
- instantclient-sdk-10.2.0.4.0-macosx-x86.zip
Install the 32-bit version of Ruby
brew install libyaml
rvm install 1.9.3 -n i386 --with-arch=i386
rvm use ruby-1.9.3-p194-i386
Bash
Add the following to your .bash_profile
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin/"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export ORACLE_HOME="/usr/local/oracle/instantclient_10_2"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH="$PATH:/usr/local/bin/"
export PATH="$PATH:/usr/local/oracle/instantclient_10_2"
Open and use a new terminal going forward.
tnsnames.ora
Create a tnsnames.ora file here:
/usr/local/oracle/network/admin/tnsnames.ora
Mine looks like this:
staging_db =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.456.789.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = FOO)
)
)
Try it
ruby -rubygems -e "require 'oci8'; OCI8.new('username','password','staging_db').exec('select * from users where rownum < 2') do |c| puts c.join(','); end;"