问题
升级电脑后,环境有些没切好,运行git init
报错,如下:
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
按照提示,运行xcode-select --install
:只安装命令行工具,不安装XCode(因为不需要XCode开发全套)。
装好之后,运行git init
依然报错:
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
执行xcode-select --install
,报错:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
此时千万不要听信提示,运行softwareupdate --install -a
或者softwareupdate --list
,第一个命令就直接去给你下载MacOS系统更新了
猜测,可能是环境路径设置问题,运行brew config
,果然,有个错误:
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
发现问题,命令行执行如下3个命令,设置环境变量
sudo xcode-select -r
将xcode开发者路径设置为默认值
sudo xcode-select --switch /Library/Developer/CommandLineTools
设置xcode开发者路径到之前安装目录下
xcode-select -p
输出xcode路径