Can sudo's annoying message be removed from Mountain Lion 10.8.0?

Solution 1:

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.

Solution 2:

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.