crh:githome crh$ git branch
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
问题分析:
初步怀疑是不是git
命令有问题了,或者说git
命令的依赖库什么的有问题
crh:githome crh$ which git
/usr/bin/git
crh:githome crh$ git -h
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
如上可以看出命令是正常被安装,但是执行起来还是报xcrun: error: invalid active developer path
的错误。
还有问题那就尝试重新安装一下git
,看看是否会解决此类错误, 不幸的是还是报错:
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
Error: Git must be installed and in your PATH!
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
从上面信息可以看出提示:不能作为二进制包安装,必须从源代码构建,需要在命令行执行xcode-select --install
来安装xcode-select.
在终端执行xcode-select --install
会跳出来安装界面,安装完成后,就可以用了。
crh:githome crh$ git -h
unknown option: -h
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
如上所示输出相应的帮助信息,意味着git已经被修复好了,可以使用了。
本文由 空心菜 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jan 14, 2019 at 09:36 am