After the upgrade to 10.8.0, whenever I do a sudo, I always get this message:

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

I have checked my .bash_profile, .zshrc all I could think of, and I don't see anything related to the DYLD_ environment.

After googling for hours, I tried to put these two lines in my .zshrc:


But the annoying message still appears.

I go to a guest account and did a sudo but didnt' get this message. So I guess I have some custom library installed... But I don't know how to debug this.


Do you have any other DYLD_ variables set? Run set with no parameters to see all variables and unset anything that comes up with that prefix.

Note that it looks like this is really just a workaround for a bug, those messages shouldn't be printed unless you have DYLD_PRINT_WARNINGS enabled.

Also, the update to 10.8.1 seems to have patched this annoyance.

  • 1
    ML bug, as far as I can tell. Those DYLD_ variables can be important, removing them might break whatever they were set for. – gabedwrds Jul 30 '12 at 4:24
  • 2
    Well, the bug is that you're not supposed to see those messages unless you set the environment variable DYLD_PRINT_WARNINGS, but for some reason Mountain Lion prints them either way. – gabedwrds Jul 30 '12 at 4:37
  • 2
    10.8.1 Didn't fix the problem – Matteo Dec 22 '12 at 14:46
  • 2
    Unsetting all DYLD_ environment variables is not a solution as they are there for a reason. It's a bug and we are stuck with it until Apple fixes it. – Matteo Dec 22 '12 at 14:47
  • 2
    I have this problem on 10.8.3 – Alex Szatmary May 1 '13 at 23:33

In zsh:

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

This spawns a sub-shell in which the environment variables that sudo complains about are unset, and then executes sudo.

Advantages over some of the other answers include:

  • Doesn't remove LD_LIBRARY_PATH and DYLD_LIBRARY_PATH from your interactive shell environment (for non-sudo commands that need it).
  • Use of a subshell ensures that if you interrupt the sudo while it's running (e.g., with Ctrl-C), your LD_LIBRARY_PATH and DYLD_LIBRARY_PATH will be unchanged in your master shell (unlike the script in another answer which sets and unsets them in the interactive shell).
  • Use of exec ensures that the otherwise-unnecessary parent shell exits immediately when invoking sudo, so there's no extra processes hanging around while the command runs.

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

  • "I'll leave it as an exercise to the reader to port to bash, et al." Because most Apple users use ZSH over the preinstalled Bash (sarcasm). – Jonathan Dumaine Jun 21 '13 at 7:47

work around found on the apple support forums by yokyoh1987,


in your .profile/.bashrc/.bash_profile (depends on you terminal setting):

# set DYLD_* for my normal programs

# set an alternative sudo
# back up the DYLD_* variables

# unset DYLD_*

# calling sudo
/usr/bin/sudo "$@"

# restore DYLD_* after sudo finished

# redirect sudo
alias sudo=thesudo
  • That's a clever little piece of env management. – bmike Dec 28 '12 at 23:17
  • One problem with this solution is that if you interrupt the sudo (e.g., via ctrl-c) your DYLD_LIBRARY_PATH var will silently be left unset in your interactive shell because the restore operation at the end will not have executed. Using a subshell (see my other answer to this question) solves this. – Pinko Feb 26 '13 at 15:56

You probably have your LD_LIBRARY_PATH set.

  • 2
    As the poster writes, he/she has already unset LD_LIBRARY_PATH, and the problem persists. – myhd Dec 22 '12 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .