Home > Software design >  Environment variable is not set MacOS
Environment variable is not set MacOS

Time:08-11

I need to set environment variables to build an Ionic application, open the terminal and run the command:

export ANDROID_SDK_ROOT=$HOME/Android/Sdk

Without closing the terminal I type echo $ANDROID_SDK_ROOT, and the environment variable is returned perfectly, so I run "source ~/.bash_profile", to update the environment variables. I open and close the terminal and my environment variable is empty! I tried to set it manually by opening the environment variables files, with a text editor but without success.

CodePudding user response:

For macOS 10.15 Catalina and Newer, you need to use a .zshenv file instead of .bash_profile. This is because, by default since Catalina, the terminal uses zsh instead of bash.

Export paths permanently in the following manner: Create .zshenv file:

touch ~/.zshenv
open -a TextEdit.app ~/.zshenv

Type out the export you want to do in this format:

export ANDROID_SDK_ROOT=$HOME/Android/Sdk

and save it. (From this old answer)

  • Related