DYLD_LIBRARY_PATH environment variable shows as empty in terminal

Hi,

I've written an application connecting to an Oracle database (written in 4D). I need to set DYLD LIBRARYPATH to /Oracle to be able to connect. I did this by creating ~/.MacOSX/environment.plist (see 1 below).
The app works fine, the variable is OK when viewed from within my application (see 2). But it shows as empty in terminal (see 3).
Why just this variable set to empty in terminal?

The actual problem I'm confronted with is a customers iBook which refuses to launch the application from the dock. DYLD LIBRARYPATH shows as empty too when launched from the dock. When double clicking in the finder all goes well...(even from an alias) What is the difference between the finder and the dock for launching an app?

TIA
Koen

This is what I get:
1. Contents of environment.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NLS_LANG</key>
<string>DUTCH_BELGIUM.WE8ISO8859P15</string>
<key>ORACLE_HOME</key>
<string>/Oracle/OCI/oci</string>
<key>ORA_NLS33</key>
<string>/Oracle/OCI/oci/ocommon/nls/admin/data</string>
<key>TNS_ADMIN</key>
<string>/Oracle/OCI/oci/network/admin</string>
<key>DYLD LIBRARYPATH</key>
<string>/Oracle</string>
</dict>
</plist>

2. env from within my application:

PATH=/usr/bin:/bin:/usr/sbin:/sbin
SECURITYSESSIONID=7ae9a790
HOME=/Users/koenvanh
SHELL=/bin/bash
USER=koenvanh
NLS LANG=DUTCHBELGIUM.WE8ISO8859P15
TNS_ADMIN=/Oracle/OCI/oci/network/admin
ORA_NLS33=/Oracle/OCI/oci/ocommon/nls/admin/data
DYLD LIBRARYPATH=/Oracle
ORACLE_HOME=/Oracle/OCI/oci
_CF_USER_TEXTENCODING=0x1F5:0:0

3. env from terminal:

TERM PROGRAM=AppleTerminal
TERM=xterm-color
SHELL=/bin/bash
NLS LANG=DUTCHBELGIUM.WE8ISO8859P15
TERM PROGRAMVERSION=133
USER=koenvanh
_CF_USER_TEXTENCODING=0x1F5:0:0
TNS_ADMIN=/Oracle/OCI/oci/network/admin
PATH=/bin:/sbin:/usr/bin:/usr/sbin
PWD=/Users/koenvanh
SHLVL=1
HOME=/Users/koenvanh
DYLD LIBRARYPATH=
LOGNAME=koenvanh
ORA_NLS33=/Oracle/OCI/oci/ocommon/nls/admin/data
ORACLE_HOME=/Oracle/OCI/oci
SECURITYSESSIONID=7ae9a790
_=/usr/bin/env

4. env from terminal after removing environment.plist:
TERM PROGRAM=AppleTerminal
TERM=xterm-color
SHELL=/bin/bash
TERM PROGRAMVERSION=133
USER=koenvanh
_CF_USER_TEXTENCODING=0x1F5:0:0
PATH=/bin:/sbin:/usr/bin:/usr/sbin
PWD=/Users/koenvanh
SHLVL=1
HOME=/Users/koenvanh
LOGNAME=koenvanh
SECURITYSESSIONID=7d0223d0
_=/usr/bin/env

PowerBook G4 12" a.o., Mac OS X (10.4.3)

Posted on Nov 15, 2005 1:01 AM

Reply
14 replies

Nov 15, 2005 2:58 AM in response to Koen Van Hooreweghe

Try logging out and then in again and see if the variable is inherited in the shell's terminal.

If you can avoid setting DYLD LIBRARYPATH, you will be doing yourself a favor. If you find the unix executable corresponding to your application, you can find where it expects the library to be located.

eg using Safari:

<code>
otool -L /Applications/Browsers/Safari.app/Contents/MacOS/Safari
</code>


There is no reason I know of for why launching from a dock alias would differ from double-clicking the icon of the application.

Nov 15, 2005 4:29 AM in response to Koen Van Hooreweghe

Hi Koen,
In your case, it looks like the environment.plist has been applied but the values have been changed. I can certainly see the necessity of that. I agree with Bill, it's terrible form to set that variable. If every app did that, the last one to set it would break all of the others. Besides that, it makes your app dependent on the user's environment. In the case of the other user, the environment.plist appears to have had no effect and again Bill is probably right; the user must logout and log back in again.

I feel confident that there are ways to set things like that in the code since most apps don't need to have that variable set. I apologize for not knowing how that's done. I don't even know how it's done in general, much less in 4D. Certainly there must be some reference information for the language that addresses such a basic need. One possibility is to launch the app from a shell script that sets all of the needed environment variables before invoking the apps actual executable. This is somewhat common and I think that if you bundle the app as an application bundle, a shell script will be invoked like other executables. I haven't tried it but think I remember seeing it done. It's certainly worth looking into.
--
Gary
~~~~
Reichel's Law:
A body on vacation tends to remain on vacation unless
acted upon by an outside force.

Nov 17, 2005 2:02 AM in response to Koen Van Hooreweghe

Hi all,

I have figured out why the variable is empty in terminal. My terminal preferences were set to execute the standard shell from /usr/bin/login. I took a look inside the login file and found a reference to /usr/lib/dyld. I guess somewhere over there the var DYLD LIBRARYPATH is set to empty. Changed the standard login shell command to /bin/bash and the environment var is OK.

Now I still have the problem of one iBook refusing to launch my app from the dock. Because the environment var is overwritten somewhere else I suppose.

I agree that setting the variable DYLD_... 'globally' using environment.plist is not a good habit. But it is the only way I could get my application working with Oracle OCI.
My app is created using 4th Dimension using 4D for OCI plugin.

I tried to add a LSEnvironment dictionary containing the environment vars to the Info.plist file, but I can't get it to work. Perhaps I have done something wrong? My application is called Vivaldi.
I edited the file Vivaldi/Contents/Info.plist using Property list editor. Beneath a fragment of the dumped contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
...
</array>
<key>CFBundleExecutable</key>
<string>EXE</string>
...
<key>LSEnvironment</key>
<dict>
<key>DYLD LIBRARYPATH</key>
<string>/Oracle</string>
</dict>
</dict>
</plist>

Nov 17, 2005 3:48 AM in response to Koen Van Hooreweghe

Hi Koen,

> Me too...

Me three! 🙂 However, as the originator of the question, you should have some link to mark Daniel's post as helpful. Neither Karl nor I can do it because only the originator has that privilege.

I wish that I could help with the local setting of your environment. I read the file to which Daniel linked and "Property List Key Reference" but I couldn't find anything wrong with your syntax. Is it your application that needs the environment variable set or is it a child of you application?

What happens if you export the environment variable in the command line and then launch your app from the command line with commands like:

export DYLD LIBRARYPATH="/Oracle"
/Applications/Vivaldi.app/Contents/MacOS/Vivaldi

Of course I assumed a default location of your Vivaldi app. (cool name by the way) You'll have to adjust that path to reflect that actual location of your app.
--
Gary
~~~~
QOTD:
"I don't think they could put him in a mental hospital.
On the other hand, if he were already in, I don't think
they'd let him out."

Nov 17, 2005 5:23 AM in response to Koen Van Hooreweghe

Try this:


mv /Applications/Vivaldi.app/Contents/MacOS/Vivaldi /Applications/Vivaldi.app/Contents/MacOS/Vivaldi.exe

touch /Applications/Vivaldi.app/Contents/MacOS/Vivaldi

Edit it, putting in the following (what is between the lines):

-------------------------------------------------------
#!/bin/bash
export DYLD LIBRARYPATH="/Oracle"
/Applications/Vivaldi.app/Contents/MacOS/Vivaldi.exe

-------------------------------------------------------


chmod a+x /Applications/Vivaldi.app/Contents/MacOS/Vivaldi


You could probably replace the absolute path with $0, but try the above first.

Nov 17, 2005 7:54 AM in response to Gary Kerbaugh

I've sometimes had a he ll of a time getting Info.plist changes to take effect...seemed like the data got cached somewhere? Try duplicating the whole .app bundle, editing the file in the copy (which is "new" to the Finder), and running the copy.

Edit: if that works, remove the old .app and rename the new one to the old name (the caching is often tied to the actual file, not the file name).

Nov 17, 2005 8:11 AM in response to Daniel Macks

LSEnvironment could be doomed as a solution here...looks like the keys in its dict are automatically prepended with the CFBundleIdentifier. The following fragment:
<pre>
<key>CFBundleIdentifier</key>
<string>foo</string>
<key>LSEnvironment</key>
<dict>
<key>FOOFOO</key>
<string>hiya</string>
</dict>
</pre>
gave me fooFOOFOO=hiya in the env. Dang.

Well, <pre> and <tt> work:)

Nov 17, 2005 11:32 AM in response to Koen Van Hooreweghe

Daniel, Bill, a.o.,

Thanks for your replies. I got it working now. And I even have a better solution.
Indeed, adding LSEnvironment dictionary to the Info.plist file is the way to set the environment variable I need.
Changes in this file don't have immediate effect. I made a copy of the application and that one worked as expected. The 'touch' command helps to get the original application file work as well.

Hip, hip, hurray!

PS: my application is named 'Vivaldi' because it is a custom database solution written for a company called "Vivaldi's interim"

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

DYLD_LIBRARY_PATH environment variable shows as empty in terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.