2013-02-15

setting environment variables for sqlplus on OSX

In my previous post I showed how to create an universal binary for Oracle instant client so I don't need to care about 32/64 bit anymore.

Now I try to show how to set some environment variables so I only need to enter sqlplus and can start my work without preparing anything first.

I know I could do this in my local .profile, but I was looking for a more centralized way to provide them, maybe on a shared desktop where basic applications are installed just once.

This is all about OSX Mountain Lion - I'm working on 10.8.2 right now.

The variables I want to set/enhance are

  • PATH
    That is quite simple: I just added (as root) a new line in /etc/paths:
    /Users/berx/instantclient_11_2

  • ORACLE_HOME
    That was a little bit more tricky as I had to create (as root) the file first. In /etc/launchd.conf
    there is one line now:
    setenv ORACLE_HOME /Users/berx/instantclient_11_2

  • DYLD_LIBRARY_PATH
    If you are curious what this is used for, it's the equivalent to Linux LD_LIBRARY_PATH. This is needed for all applications which are linked dynamically. Even sqlplus is linked that way.
    Unfortunately it can not be set in /etc/launchd.conf. To be more precise, it CAN be set, but it will not show up in the terminal.
    Instead it will create this line at the top of each terminal window direct after it opens:
    dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/login) is setuid or setgid
    That's due to a security setting in Mountain Lion.
    I decided to use the profile for this work. In my case ~/.profile, but /etc/profile also works:
    # ORACLE_HOME is set in /etc/launchd.conf !!
    export DYLD_LIBRARY_PATH=$ORACLE_HOME:$DYLD_LIBRARY_PATH

With these 3 little steps now I can start sqlplus directly from my terminal without caring about the environment anymore.

There is just one little drawback: all commands with setuid/setgid bit, like ps or sudo now throw a warning like this:
dyld: DYLD_ environment variables being ignored because main executable (/bin/ps) is setuid or setgid
But for me this is acceptable.

The only workaround I could imagine is any kind of wrapper for sqlplus.

Keine Kommentare: