Mac OS环境变量设置

由于安装xcode之前,自己误打误撞地装了gcc,装了xcode之后,使用brew install wget总是提示找不到c编译器或者make失败。

其实这个时候只要brew doctor,然后在终端会给出很多提示。

最终我的解决方案是需要修改环境变量,将/usr/local/bin放在/usr/bin的前面即可。这样在寻找gcc编译器的时候会优先使用该目录下的程序代码。

具体方案是:

1)查看当前环境变量

$PATH

2)如果不对

cd ~

vi .bash_profile

3)使用vi修改

按下i开始修改

输入 export PATH = /usr/local/bin;$PATH

按下ESC

:wq保存修改

source ./.bash_profile


brew doctor

/usr/bin is in your PATH before Homebrew's bin. This means that system-
provided programs will be used before Homebrew-provided ones. This is an
issue if you install, for instance, Python.
Consider editing your .bashrc to put:
  /usr/local/bin
ahead of /usr/bin in your $PATH.
原文地址:https://www.cnblogs.com/1000/p/2376443.html