48

since an update to 10.8 I get the following error, when trying to do a sudo command, which is pretty annoying.

dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid

What does that have to mean? I hope anyone can help.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
eneskaya
  • 918
  • 1
  • 10
  • 17
  • For me, I found that if you install XCode and probably also the Command Line Tools component, that this warning stops. – EMiller Apr 22 '13 at 15:45

7 Answers7

43

This seems to be a bug introduced in 10.8, see this report. As far as I can tell, the only workaround is not setting DYLD_LIBRARY_PATH or LD_LIBRARY_PATH by default, but only when needed.

Erik Hesselink
  • 2,420
  • 21
  • 25
  • 1
    Ok. In my .bash_profile I just commented out `export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH`. I don't quite know what I did there, but at least this annoying message stopped. Hope this'll get fixed soon – eneskaya Aug 22 '12 at 18:12
  • @eneskaya: I think I read somewhere that there used to be buggy mysql versions that had the wrong path to the libraries embedded. Setting that DYLD_LIBRARY_PATH was the solution. If mysql still works for you, I guess they fixed it. – Erik Hesselink Aug 22 '12 at 18:33
  • @eneskaya: Are you using mySQL? Does mySQL still work for you? – tholu Oct 23 '12 at 20:30
  • 1
    I added `unset LD_LIBRARY_PATH` in `~/.profile`, and the annoying message disappeared. – neevek Oct 27 '12 at 11:50
  • 4
    This will break sql for me if I do that. – jahrichie Nov 08 '12 at 14:08
  • 2
    I would recommend using the sudo function below: sudo () { ( unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH; exec command sudo $* ) }. It works in BASH, as well, and is elegant. Just place it in your .bashrc and source it (. .bashrc). – speeves May 20 '13 at 15:36
20

In zsh:

sudo () { ( unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH; exec command sudo $* ) }

This spawns a sub-shell in which the environment variables sudo complains about are unset, and then executes sudo (via exec so that the now-unecessary parent shell exits immediately).

I'll leave it as an exercise to the reader to port to bash, et al.

Pinko
  • 3,309
  • 2
  • 20
  • 15
  • 1
    Tried putting this line of command in /etc/bashrc (need `chmod +w /etc/bashrc` to allow write permission) and the warning message is gone, thanks! – Ken Pega Jul 31 '13 at 00:53
7

Not sure where the official solve is for this, but I solved it with this bashrc hack, because I couldn't deal with seeing that damn warning any longer.

put this in the /etc/bashrc or wherever yours lives.

# set DYLD_* for my normal programs
DYLD_LIBRARY_PATH='..'
 
# set an alternative sudo
thesudo()
{
# back up the DYLD_* variables
local BACK=$DYLD_LIBRARY_PATH
# unset DYLD_*
unset DYLD_LIBRARY_PATH
# calling sudo
/usr/bin/sudo "$@"
# restore DYLD_* after sudo finished
export DYLD_LIBRARY_PATH=$BACK
}
 
# redirect sudo
alias sudo=thesudo
Community
  • 1
  • 1
jahrichie
  • 1,215
  • 3
  • 17
  • 26
5

Those who use django (python for web), with mysql through MySQLdb (Mysql-Python module), need that variable set. So I just keep the warning for now.

iannakin
  • 69
  • 1
  • 7
1

It seems the already mentioned "fixes" are just workarounds that may not work for all users. This is a known bug that Apple is (at least) aware of: http://openradar.appspot.com/11894054

1

This issue is finally fixed on OS X Mavericks (10.9), the message no longer comes up on sudo.

Giannis
  • 486
  • 6
  • 8
-1

Not sure if this is a true fix, but this error disappeared when I ran Clean Build Folder