Jeff Taylor's Weblog

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


$ otool -L /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:


$ 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.

Join the discussion

Comments ( 2 )
  • Hans Forbrich Thursday, March 24, 2016

    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

  • Kyle Hailey Thursday, December 1, 2016

    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


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.