解决 Mac 升级为 Big Sur 系统后 Homebrew 命令失效的问题

今天老王在 MacBook 上用 Homebrew 更新软件包时,所有 brew 命令均报错:/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize’: Version value must be a string; got a NilClass () (TypeError),本文分享下解决方法。

一、报错内容

所有 Homebrew 的命令都无法执行,例如运行 brew list 会报如下的错误:

解决 Mac 升级为 Big Sur 系统后 Homebrew 命令失效的问题

错误内容以及详细信息:

Traceback (most recent call last):
11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
9: from /usr/local/Homebrew/Library/Homebrew/global.rb:37:in `<top (required)>'
8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /usr/local/Homebrew/Library/Homebrew/os.rb:3:in `<top (required)>'
5: from /usr/local/Homebrew/Library/Homebrew/os.rb:21:in `<module:OS>'
4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:58:in `prerelease?'
3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `version'
2: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `new'
1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:26:in `initialize'
/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize': Version value must be a string; got a NilClass () (TypeError)

更多关于 Homebrew 的介绍:《Mac 上 Homebrew 介绍和常用命令整理

二、解决办法

造成这个 Homebrew 失效的原因可能是 Mac 在升级成 Big Sur 系统后(本文测试系统:macOS Big Sui Version 11.1),旧版本的 Homebrew 不适配了,不过老王搜了下发现最新版的 Homebrew 已经解决了这个错误,所以我们只需要更新到新版本的 Homebrew 即可:

brew update-reset

之后再执行brew list 就正常了:

brew list

赞(7)
关注我们
未经允许不得转载:老王博客 » 解决 Mac 升级为 Big Sur 系统后 Homebrew 命令失效的问题

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址