由于我把环境变量配置都写在了~/.bash_profile中,而终端默认使用zsh,导致添加的环境变量不生效。每次打开都需要输入一遍source ~/.bash_profile。 🍀解决方法 方法一:使用zsh的环境变量配置文件 这种需要重新写入一遍配置,挺麻烦的。 方法二:打开终端时,自动输入source ~/.bash_profile 只需要在~/.zshrc文件中加入source ~/.bash_profile。 这种方法只在交互shell中有用。