zsh: command not found: adb in mac OS
Asked Answered
B

2

7

I am getting zsh: command not found: adb error even after updating my .zshrc file. I have added the following path in my .zshrc file

# For ADB
export ANDROID_HOME=/Users/aanshu/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH

declare -p PATH is returning the following path

export -T PATH path=( /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /Users/aanshu/.nvm/versions/node/v12.16.1/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin )
Basketball answered 14/6, 2022 at 17:42 Comment(13)
Where is your actual adb executable? If you run declare -p PATH, does it reflect this configuration, showing the extra entries it's intended to add?Plot
I did not understand are you talking about path ?Basketball
The PATH is the variable you're setting to tell the shell where to look for executables. If you run echo "$PATH" or declare -p PATH it will show the actual value.Plot
If your edited file was never invoked, then showing the PATH won't show the changes you made. We need to know if that's the case.Plot
Part of the problem is that you're pointing ANDROID_HOME at the wrong place. It shouldn't point all the way to the adb executable; it should point to the .../Library/Android/sdk directory.Plot
export -T PATH path=( /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /Users/aanshu/.nvm/versions/node/v12.16.1/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools/bin /Users/aanshu/Library/Android/sdk/platform-tools/adb/tools Basketball
/Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-tools /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin )Basketball
Thank you for the above (but for the future, such content should be edited into the question instead of just added as comments). The other thing: What's the output of find /Users/aanshu/Library/Android/sdk -name adb -type f -print?Plot
...basically, once you have the find output, you need to make sure that the directory containing the adb executable (not the executable itself, but its parent directory) is one of the things shown in the dumped PATH list.Plot
...I suspect that the real location of the executable is /Users/aanshu/Library/Android/sdk/platform-tools/adb; but instead of adding /Users/aanshu/Library/Android/sdk/platform-tools to the PATH, you're instead adding /Users/aanshu/Library/Android/sdk/platform-tools/adb/platform-toolsPlot
yes that was the issue @CharlesDuffy I was adding the incorrect pathBasketball
Why would you edit a bash config file if you're using zsh?Soilure
@Soilure sorry i mean .zshrc fileBasketball
P
8
export ANDROID_HOME=/Users/aanshu/Library/Android/sdk/platform-tools/adb

...is obviously wrong. It should instead be:

export ANDROID_HOME=/Users/aanshu/Library/Android/sdk

...because it provides a base to which the subsequent lines append.

Plot answered 14/6, 2022 at 17:42 Comment(1)
@qkx, the code in your comment above is overriding PATH, not appending to it. Nothing at all in this answer tells you to do that, so I don't know why you're blaming me.Plot
A
7

Sorry to answer this this lately .. For me these are the things that I did.

  • • Copy the platform-tools to the user home folder
  • • Then opened terminal and entered “ nano .zshrc ”
  • • In that text editor I added the below line

export PATH=$PATH:/Users/user_name/android-sdk-macos/platform-tools/

  • then save it user control+x and exit the text editor

  • • In the terminal I entered “ source ~/.zshrc “

  • • Closed all terminals and reponed it.

    That’s it

Then I tried adb devices in the terminal to test if it works or not. and It was working

Abram answered 7/2, 2023 at 13:50 Comment(2)
"In that text editor I added the below line - o export" what is that supposed to mean?Siltstone
@BorisGafurov sorry brother.. the command was like this.. " export PATH=$PATH:/Users/user_name/android-sdk-macos/platform-tools/ " forgot to add newline after " - o"Abram

© 2022 - 2024 — McMap. All rights reserved.