Mac下配置了环境变量但是只在当前命令行窗口内有效,关闭之后重新打开就又需要输入
source .base_profile
才能生效,出现的原因是因为系统默认使用的是zsh终端导致,然后网上已经有很多种解决方案了,但是我自己试了都是没有效果,最终直接将.base_profile
内的环境变量全部复制到.zshrc
文件内。
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/xxx/.oh-my-zsh"
export PATH=/Users/xxx/Development/flutter/bin:$PATH
export ANDROID_HOME="/Users/xxx/Library/Android/sdk"
export PATH=${PATH}:/Users/xxx/Library/Android/sdk/platform-tools
export PATH=${PATH}:/Users/xxx/Library/Android/sdk/tools
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
最后在终端内输入source .zshrc
立即生效,问题得到解决。