brew报错Version value must be a string; got a NilClass () (TypeError)

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出了问题

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值