Reputation: 4731
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 ?
Upvotes: 0
Views: 589
Reputation: 2756
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
)
Upvotes: 1