1、发现问题
在 ~/.bash_profile 中配置环境变量, 可是每次重启终端后配置的不生效.需要重新执行 : source ~/.bash_profile ,在.bash_profile中配置的环境变量才能生效。
后来发现zsh加载的是 ~/.zshrc文件,而 .zshrc文件中并没有定义任务环境变量(或者此文件不存在)。
2、解决办法
在~/.zshrc(不存在则创建它)文件最后,增加一行:
source ~/.bash_profile
3、.bash_profile 和 .zshrc的区别:
-
.bash_profile 和 .zshrc 均在~目录下。
-
.bash_profile,source ~/.bash_profile,只在当前窗口生效。
-
.zshrc ,source ~/.zshrc,永久生效;计算机每次启动自动执行source ~/.zshrc。
-
一般会在~/.zshrc中添加source ~/.bash_profile,以确保.bash_profile中的修改永久生效。。