简体   繁体   中英

adb command not found even after setting path in mac

I have set following path in my bash_profile file:

export ANDROID_HOME=/Users/viki-donor/Library/Android/sdk
export PATH=$ANDROID_HOME/build-tools/26.0.2:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH

I saved it and ran the command source ~/.bash_profile . If I type adb the command is running successfully. But after sometime. If I run the same command adb its not able to recognize the command and I get command not found error. I again run source ~/.bash_profile and it starts working fine. Why do I have to run source ~/.bash_profile again and again ?

Note: This only applies if you are using bash as your shell. Other shells have other scripts.

To ensure that the settings are loaded in non-login shells, you should add it to the .bashrc file in your home directory.

(It often makes sense to have this in your .bash_profile ):

[[ -f ~/.bashrc ]] && . ~/.bashrc

This means that your bashrc is always loaded, whether it is a login shell or not.

For settings that should apply to all users, you can usually create a .sh file in /etc/profile.d/ with the settings or edit /etc/bashrc (or /etc/bash.bashrc in some cases) (and /etc/profile )

(There are often better methods to set environment variables, like /etc/environment on Linux boxes using pam_env )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM