dyld: warning, unknown environment variable: DYLD_

2019-07-18 07:37发布

问题:

I used the bundled Property List Editor of Mac OS X Developer Tools to set an environment variable DYLD_LIBRARY_PATH_64-bit to the value path/to/dylib in the file ~/.MacOSX/environment.plist. I saved this file and logged out.

Upon logging back in, the console displayed multiple messages of "dyld: warning, unknown environment variable: DYLD_LIBRARY_PATH_64-bit." I removed the entry from environment.plist with the Property List Editor, saved the file and logged out.

I logged back in, and the warning message persists. The dyld man page displays a list of constants which appear similar to my wayward environmental variable, as they all start with "DYLD_." A source file, dyld.cpp, shows an else after a long line of DYLD constants, with code to print the very same warning message. Maybe I flew too close to the sun of environmental variable naming. I thought we were free!

I tried update_dyld_shared_cache to no avail. Perhaps I am missing some important flags?

I added "setenv DYLD_LIBRARY_PATH_64-bit path/to/dylib" to /etc/launchd.conf in an attempt to add a (apparently malformed) environmental variable to my paths, hoping that if it showed up, I could delete it - without success.

From the command-line, export does not show DYLD_LIBRARY_PATH_64-bit. Here's some sample output:

$ unset $DYLD_LIBRARY_PATH_64-bit 
-bash: unset: -b: invalid option

$ echo $DYLD_LIBRARY_PATH_64-bit
-bit

$ unset DYLD_LIBRARY_PATH_64-bit
-bash: unset: `DYLD_LIBRARY_PATH_64-bit': not a valid identifier

The moral of the story is to never use Property List Editor, at least with dynamic library paths. Well no - the moral of the story is never use the dash at the end of environmental variable names, since they look like flags.

With that said, do ya'll have any recommendations for getting rid of this masquerading environmental variable, and of cleaning my console of repeated dyld warnings?

Thanks!

回答1:

Here's one way to solve an invisible environment variable inadvertently set by the Property List Editor: re-format the machine. Clean it. Clean it with fire.

A sobering lesson for all of us, and especially myself. Use not the dash in your environment variables when using Property List Editor, lest you be riddled with dyld: warning messages for all the days of your machine. Woe to the motherboard, for her CPU is barren of productivity, and instead she is reduced to printing messages to file 2 (standard error).

No seriously: Property List Editor will let you specify bogus environmental variables that Bash would never let you get away with. In the sense of "the user must know what he's doing," Mac OS X becomes UNIX-like.



回答2:

Actually if you set any env var that starts with DYLD_ that isn't in the apples list you get a nag message.

I am hoping there is a flag to turn this off



回答3:

What worked for me on a similar problem with a DYLD libarary path variable which wouldn't go away on a mac:

Use the unset command, and the for good measure, after I unset it I exported it again...

i.e. something like

$ unset DYLD_LIBRARY_FALLBACK_PATH    
$ export DYLD_LIBRARY_FALLBACK_PATH