0

I am trying to set permanent environmental variable in my mac machine I have tried following steps till now -

  1. vi ~/.bash_profile
  2. adding my variable

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
    export ANDROID_HOME=/usr/local/share/android-sdk
    export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
    
  3. restarted the bash

    source ~/.bash_profile
    

For current terminal its loaded the variable, but if I open another terminal its not showing newly added variable if I check with printenv.

How can I make bash set the variables?

2
  • 2
    source doesn't restart, it just reads the file. Did you check whether you actually are using bash or whether you run zsh instead (which is the default for newly created accounts in Catalina)? – nohillside Jan 24 '20 at 7:07
  • 1
    @nohillside by defualt its zsh, and thanks u guided to the right direction , i need to add in .zshrc , now its working fine – Dilip Jan 24 '20 at 7:16
2

For newly created accounts Catalina uses zsh instead of bash, so you need to add the lines to the appropriate file (probably ~/.zshenv to make sure it's read in all cases).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .