sqlplus and DYLD_LIBRARY_PATH on Mac OS/X

At some point in the past I followed directions in "Oracle Database Client Installation Guide for Apple Mac OS X (Intel)" so that I could use sqlplus on my MacBook. Following the directions, I set the DYLD_LIBRARY_PATH environment variable in my .bashrc.

Today, I noticed this:

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Setting DYLD_* vars can break dynamic linking.
Set variables:
    DYLD_LIBRARY_PATH: :/Applications/instantclient_11_2

Hmm, what to do? Ignore? Fix? Google?

The top google hit was "Oracle sqlplus and instant client on Mac OS/X without DYLD_LIBRARY_PATH".

Everything is Casey's blog checked out:

$ which sqlplus
/Applications/instantclient_11_2/sqlplus

$ otool -L /Applications/instantclient_11_2/sqlplus
/Applications/instantclient_11_2/sqlplus:
    /ade/b/1891624078/oracle/sqlplus/lib/libsqlplus.dylib (compatibility version 0.0.0, current version 0.0.0)
    /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 0.0.0)
    /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

When I unset the variable, sqlplus stopped working:

$ unset DYLD_LIBRARY_PATH

$ sqlplus
dyld: Library not loaded: /ade/b/1891624078/oracle/sqlplus/lib/libsqlplus.dylib
  Referenced from: /Applications/instantclient_11_2/sqlplus
  Reason: image not found
Trace/BPT trap: 5


sqlplus cannot be opened because of a problem. Check with the developer to make sure sqlplus works with this version of OS X. You may need to reinstall the application. Be sure to install any available updates. Ignore. Report.

SIMPLE SOLUTION: I was about to follow Casey's instructions when a simpler solution popped into my mind. I removed the DYLD_LIBRARY_PATH environment variable from my ~/.bashrc and replaced it with an alias:

alias sqlplus="DYLD_LIBRARY_PATH=/Applications/instantclient_11_2 sqlplus"

After killing the OS X Terminal and restarting, and verifying that the environment variable was gone and alias present, both "brew doctor" and "sqlplus" were happy.

DISCLAIMER: My alias only addresses sqlplus usage. If you are using more Instant Client functionality, you may need to use Casey's solution or bluebinary's solution. I can't vouch for either Casey's solution or bluebinary's solution, but both approaches seem reasonable.

Comments:

You might want to consider SQLcl, which is a Java-based counterpart to SQLPlus. It's available through the SQLDeveloper download page.

I'm pleased at how closely compatible to SQLPlus it is, and excited that is also includes history and command scrolling

Posted by Hans Forbrich on March 24, 2016 at 03:20 PM EDT #

wow Jeff - you rock.
I never would have thought of this solution.
Little grumpy ... this day and age junk like this blows an hour or two and the friction demotivates.

Also Casey's solution didn't work for me

Kyle

Posted by Kyle Hailey on December 01, 2016 at 03:18 PM EST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Jeff Taylor-Oracle

Search


Archives
« March 2017
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today