0

Currently I am using macOS Catalina, however this is same for couple of versions.

on /etc/zprofile (or /etc/profile when using bash back on old versions) I have such content by default:

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

In addition, I have create a file in /etc/paths.d/android. Content is

/Users/$USER/Library/Android/sdk/platform-tools
/Users/$USER/Library/Android/sdk/tools
/Users/$USER/Library/Android/sdk/tools/bin

However when I launch terminal, terminal is not able to find my binaries in those folders:

zsh: command not found: adb

Don't know why, but workaround is duplicating path helper line as following?

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
    eval `/usr/libexec/path_helper -s`
fi

So, here is my question, why is this happening and how this workaround actually works?

I got bored workaround because it is just deleted every update.


** Edit **

without duplication:

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

with duplication:

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
2
  • 1
    Please copy-paste the output of /usr/libexec/path_helper -s, and the output of print -lr -- $path[@] with and without the duplication of the eval … line. Oct 30 '19 at 9:42
  • @Gilles'SO-stopbeingevil' you are a smart guy, it reveled problem. however still don't know how work around(!) works. output is added to the question
    – guness
    Oct 30 '19 at 10:09
0

As a solution this is what I have done, I am still open to alternative solutions but putting mine as reference here.

if [ -x /usr/libexec/path_helper ]; then
    paths=`/usr/libexec/path_helper -s`
    eval ${paths//'\$USER'/$'$USER'}
fi

it is just because first path_helper call generates path variable with escaped string as following: /Users/\$USER/Library and my fix is to unescape before evaluating.


Still, thanks to @Gilles 'SO- stop being evil' for helping me identify problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.