Homebrew reports an error after upgrading MacOS to Big Sur

Question

Homebrew reports an error after upgrading MacOS to Big Sur, as follows:

$ 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)

terms of settlement

Modify the/usr/local/library/homebrew/version.rb file and change @ version in the initialize function to a specific value, such as:

  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

Change to

  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

Read More: