MacOS升级到Big Sur后Homebrew报错

Posted kongxx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MacOS升级到Big Sur后Homebrew报错相关的知识,希望对你有一定的参考价值。

问题

MacOS升级到Big Sur后Homebrew报错,如下:

$ brew
Traceback (most recent call last):
	23: from /usr/local/Library/Homebrew/brew.rb:6:in `<main>'
	22: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	21: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	20: from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>'
	19: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	18: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	17: from /usr/local/Library/Homebrew/extend/pathname.rb:4:in `<top (required)>'
	16: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	15: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	14: from /usr/local/Library/Homebrew/utils.rb:2:in `<top (required)>'
	13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /usr/local/Library/Homebrew/emoji.rb:24:in `<top (required)>'
	10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /usr/local/Library/Homebrew/extend/os/emoji.rb:1:in `<top (required)>'
	 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 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /usr/local/Library/Homebrew/os.rb:1:in `<top (required)>'
	 4: from /usr/local/Library/Homebrew/os.rb:18:in `<module:OS>'
	 3: from /usr/local/Library/Homebrew/os/mac.rb:21:in `version'
	 2: from /usr/local/Library/Homebrew/os/mac.rb:21:in `new'
	 1: from /usr/local/Library/Homebrew/os/mac/version.rb:26:in `initialize'
/usr/local/Library/Homebrew/version.rb:198:in `initialize': Version value must be a string; got a NilClass () (TypeError)

解决办法

修改 /usr/local/Library/Homebrew/version.rb 文件,将其中 initialize 函数中的 @version 改为具体的值,比如:

  def initialize(val)
    if val.respond_to?(:to_str)
      @version = val.to_str
    else
      raise TypeError, "Version value must be a string; got a #val.class (#val)"
    end
  end

改为

  def initialize(val)
    if val.respond_to?(:to_str)
      @version = '10.15.7'
    else
      raise TypeError, "Version value must be a string; got a #val.class (#val)"
    end
  end

以上是关于MacOS升级到Big Sur后Homebrew报错的主要内容,如果未能解决你的问题,请参考以下文章

MacOS升级到Big Sur后Homebrew报错

MacOS升级到Big Sur后Homebrew报错

MacOS升级到Big Sur后Homebrew报错

macOS升级Big sur后homebrew实效的问题

MacOS系统升级到Big Sur后CMake报xcode-select错误的解决办法

MacOS系统升级到Big Sur后CMake报xcode-select错误的解决办法