Home > front end >  Why do my $PATH environment always reset after I open a new terminal on my mac?
Why do my $PATH environment always reset after I open a new terminal on my mac?

Time:02-14

Usually I will nano .zsh_profile Then I will edit the path

#PYTHON
export PATH=/Users/ffff/Library/Python/3.8/bin:$PATH

# JAVA
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

#ANDROID
export ANDROID_HOME=/Users/ffff/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH

then I will save and exit Then I will

source .zsh_profile

I will test the Java and ADB all is good, but one I open a new Terminal from my mac, it will say ADB and JAVA and Android_HOME not found

Why is it not persist? Did I miss out anything? My mac version is 12.2.1

CodePudding user response:

The .zsh_profile file executes for login shells, you probably have some code in your .zshrc file, that overrides the PATH variable with something else. Because, as oppsed to .zsh_profile, the .zshrc file gets executed for every interactive non-login shells.

So my advice, checkout .zshrc and see if there's something overriding the PATH there, if so, maybe you want to append your code at the end of the .zshrc file instead.

  • Related