mac系统homebrew突然出问题
shell中输入brew --version报错
/usr/local/Homebrew/Library/Homebrew/version.rb:198:in `initialize': Version value must be a string; got a NilClass () (TypeError)
from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:26:in `initialize'
1.根据网友方法,加入@version = '11.6'
搜索说是版本号问题,修改 /usr/local/Homebrew/Library/Homebrew/version.rb 文件,加上一行@version = '11.6'
def initialize(val)
unless val.respond_to?(:to_str)
raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
end
@version = val.to_str
@version = '11.6'
end
继续报错,提示如下。
brew --version
Homebrew >1.2.0 (no git repository)
Homebrew/homebrew-core (no git repository)
--------------如果方法1失败------------------方法2.卸载重装brew
卸载:open /usr/local 直接找到homebrew文件夹删了
重装:/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
报错:
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.
根据提示,shell中输入命令sudo xcode-select --switch path/to/Xcode.app,这句话就是指定xcode路径,可能电脑里装了很多个 版本xcode
继续报错xcode-select: error: invalid developer directory 'path/to/Xcode.app',这句话可能是说path/to/Xcode.app这个路径下没有xcode
然而我系统里其实早就下了xcode-select,xcode-select --version没报错。怀疑是路径问题,也不知道咋修改,也看不懂,想着直接去application里下个可能就对了。
解决:打开mac自带的application界面找到xcode下载。
安装好xcode以后重新安装brew
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
竟然成功了,咱也不知道为啥,也不是很重要。目标也就是修复下brew。
总结:可能就是xcode出了问题