1.在终端当中直接输入 sudo vim ~/.bash_profile 输入密码 2.在bash_profile当中输入需要添加的环境变量 export PATH=/opt/homebrew/bin:$PATH 如果你的shell是bash的话到这里就可以结束了,但是我的shell是zsh 查看shell是什么的方法:echo $0 3.在终端当中输入 sudo vim ~/.zshrc 输入密码 4.在zshrc当中添加 source ~/.bash_profile