Ruby oci8 with Rails 3.1 on Ubuntu


12.08.11 Posted in Blog by admin

ruby-oci8 is the gem to use Oracle as the database for your Rails 3.1 application. Getting it to work can be a ‘little’ tricky. In this post, I’ll try to summarize how to get it to work on Ubuntu for a Rails 3.1 application.

Well, let’s start with the basics. Before you try your luck with the magnificent ‘bundle install’,  halt! Stop right there and do THIS first :D

1. Install Oracle Instantclient. Get started with that here. Its pretty straightforward and shouldn’t be a problem.

2. Post that, you need to set the environment variable LD_LIBRARY_PATH. Do it now by typing in :

export LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/"

in your user profile file ie ‘.bashrc’ or ‘.bash_profile’. Reload it by typing:

source .bashrc

Also, check that this location does have the client installed. If not, find out where it is and create a soft link to here. ruby-oci8 expects to find it at this location “/usr/lib/oracle/….”.

3. Lastly, set this link:

sudo ln -s /usr/include/linux/ /usr/include/sysclient

One more thing, try typing:

echo $ORACLE_HOME

It should be set to where your Oracle is installed. If it isn’t set, set it in your user profile file again with ‘export’.

That’s it. We are done. Try running ‘bundle install‘ or ‘gem install ruby-oci8‘ and it should work. Well, it should. If it didn’t, well, I’m sure its Oracle, not you :D In any case, drop in a comment and maybe I can help. For the rest of the ‘process’, I’ve written a follow up post here. Happy DBing :)



Leave a Reply

 
February 2012
M T W T F S S
« Dec    
 12345
6789101112
13141516171819
20212223242526
272829  
Social Media
Get in Touch
contact[at]jigyasamakkar[dot]com