Why do my environment variables keep getting wiped out in Mac OS Catalina?

I am currently using MacOS Catalina, and every time my computer boots up from having shut down the environment variables get wiped out. I literally have to manually run export FOO=bar each time my computer boots up.

I have tried adding the environment variables to ~/.bash_profile but that doesn't seem to work, I think because Catalina uses zsh as opposed to bash. (Is there a way to switch back?)

Anyways, how do I persist environment variables so that I don't have to manually export them every time? Could something be wrong with my computer that's causing this? There are also some other weird issues when my computer does a fresh boot.


You need to create a file ~/.zshrc and put your export statements in there. The shell does not magically remember what you exported last time. You will need to put them in a file that will get sourced each time you start your shell, such as .zshrc.