目前我正在使用 macOS Catalina,但是这对于几个版本是相同的。
在/etc/zprofile
(或/etc/profile
在旧版本上使用 bash 时)我默认有这样的内容:
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
另外,我在/etc/paths.d/android
. 内容是
/Users/$USER/Library/Android/sdk/platform-tools
/Users/$USER/Library/Android/sdk/tools
/Users/$USER/Library/Android/sdk/tools/bin
但是,当我启动终端时,终端无法在这些文件夹中找到我的二进制文件:
zsh: command not found: adb
不知道为什么,但解决方法是复制路径帮助行如下?
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
eval `/usr/libexec/path_helper -s`
fi
所以,这是我的问题,为什么会发生这种情况以及这种解决方法实际上是如何工作的?
我对解决方法感到无聊,因为它只是在每次更新时都被删除。
** 编辑 **
没有重复:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/\$USER/Library/Android/sdk/platform-tools:/Users/\$USER/Library/Android/sdk/tools:/Users/\$USER/Library/Android/sdk/tools/bin:/Users/\$USER/Library/Flutter/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/$USER/Library/Android/sdk/platform-tools:/Users/$USER/Library/Android/sdk/tools:/Users/$USER/Library/Android/sdk/tools/bin:/Users/$USER/Library/Flutter/bin"; export PATH;
print -lr -- $path[@]
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/Users/$USER/Library/Android/sdk/platform-tools
/Users/$USER/Library/Android/sdk/tools
/Users/$USER/Library/Android/sdk/tools/bin
/Users/$USER/Library/Flutter/bin
/Applications/Wireshark.app/Contents/MacOS
有重复:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/\$USER/Library/Android/sdk/platform-tools:/Users/\$USER/Library/Android/sdk/tools:/Users/\$USER/Library/Android/sdk/tools/bin:/Users/\$USER/Library/Flutter/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/$USER/Library/Android/sdk/platform-tools:/Users/$USER/Library/Android/sdk/tools:/Users/$USER/Library/Android/sdk/tools/bin:/Users/$USER/Library/Flutter/bin:/Users/guness/Library/Android/sdk/platform-tools:/Users/guness/Library/Android/sdk/tools:/Users/guness/Library/Android/sdk/tools/bin:/Users/guness/Library/Flutter/bin"; export PATH;
print -lr -- $path[@]
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/VMware Fusion.app/Contents/Public
/Users/$USER/Library/Android/sdk/platform-tools
/Users/$USER/Library/Android/sdk/tools
/Users/$USER/Library/Android/sdk/tools/bin
/Users/$USER/Library/Flutter/bin
/Applications/Wireshark.app/Contents/MacOS
/Users/guness/Library/Android/sdk/platform-tools
/Users/guness/Library/Android/sdk/tools
/Users/guness/Library/Android/sdk/tools/bin
/Users/guness/Library/Flutter/bin