ene*_*aya 48 macos command-line sudo dyld osx-mountain-lion
因为更新到10.8我在尝试执行sudo命令时遇到以下错误,这非常烦人.
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
Run Code Online (Sandbox Code Playgroud)
这意味着什么?我希望有人能提供帮助.
Pin*_*nko 20
在zsh中:
sudo () { ( unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH; exec command sudo $* ) }
Run Code Online (Sandbox Code Playgroud)
这会产生一个子shell,其中sudo抱怨的环境变量未被设置,然后执行sudo(通过exec,以便现在不必要的父shell立即退出).
我将把它作为练习留给读者移植到bash等人.
不知道官方解决方案的目的在哪里,但是我用这个bashrc hack解决了它,因为我无法再看到该死的警告了.
# 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
Run Code Online (Sandbox Code Playgroud)