macOS problem zsh: command not found: adb
Table of contents
1. Problem description
1. I bought a new Macbook Pro for development, and the above problem occurred when using the ADB command zsh: command not found: adb , as shown in the figure below:
2. Macbook Pro 2020 version, system version 10.15.5. Before 2020 This problem may occur when the MacBook or the system before version 10.15.5 is upgraded to the system 10.15.5.
2. Problem Analysis
The literal meaning of the prompt is that the relevant command was not found.
In fact, bash shell and zsh shell are two kinds of reading system environment variables.
The premise of using adb is that the environment variables related to the android tool have been configured in the .bash_profile of bash, so that the adb command can be used.
However, when using the zsh shell, the configuration of related environment variables is not set in .zshrc (similar to bash's .bash_profile in function).
therefore,The solution is to add environment variables for configuring android tool in .zshrc.
Note: In Mac, some are .zshrc, and some systems are zshrc, which is a hidden file. Hide and show hidden files under Mac
3. Solutions
3.1 Open the .zshrc file
Open the terminal and enter open .zshrc
Note: Some systems may encounter problems
, then enter open zshrc
to manually find the .zshrc file location /private/etc
3.2 Edit the .zshrc file
Find the "# User configuration" position in the .zshrc file and add "source ~/.bash_profile" (provided that the environment variables in the bash_profile file have been configured in various ways)
3.3 Save the file
Execute source .zshrc or source zshrc, or manually control+S to save.
3.4 Verification
If you enter adb version in the terminal,
there may still be problems.
Then copy zshrc to the directory /Users/yourname for the
next copy. Enter adb version in the terminal again. If the following figure appears, it means that the configuration is successful, and you can use the ADB command to debug normally.