Ubuntu + Rails + Passenger + OCI8 = Sad
LoadError (Oracle/OCI libraries could not be loaded: libclntsh.so.11.1: cannot open shared object file: No such file or directory — /usr/local/lib/site_ruby/1.8/i486-linux/oci8lib.so)
Have you seen this error in your Rails application? Do you hate it as much as I do? I’ve spent the past two days troubleshooting this and I finally found a solution. It’s ugly and hacky, but it appears to be working.
There are actually quite a few posts out there regarding this error and they all get down to the root problem: the LD_LIBRARY_PATH environment variable is not available to the Apache user (www-data in this case). Most solutions I’ve found involve setting this variable in /etc/bash.bashrc or /etc/profile to make the variable available to all users. This fixed part of the problem for me, but it was still failing when executed from Apache via Passenger.
The “solution”
The hacktastic solution was to modify the /etc/init.d/apache2 startup script and explicitly set the LD_LIBRARY_PATH variable when Apache is started. Specifically, change
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
to
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin LD_LIBRARY_PATH=/opt/oracle/instantclient"
Note that this solution assumes you’re using the Oracle InstantClient; if you’re using the full Oracle client, you may try setting the ORACLE_HOME path instead of LD_LIBRARY_PATH.
I hope this helps somebody!
2 comments
Great guy!
I was like… 5 hours to make this work.. and now its working!!
Thanks a lot!
Really helpful.
Comment on this post