macOS12 brew 报错 提示不支持解决办法
苹果于6月8日发布了 macOS12,但是brew 还没有及时更新,所以暂时提示不支持。
报错如下:
shell
Traceback (most recent call last):
11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>'
10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
9: from /usr/local/Homebrew/Library/Homebrew/global.rb:80: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:7:in `<top (required)>'
5: from /usr/local/Homebrew/Library/Homebrew/os.rb:43:in `<module:OS>'
4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:65:in `prerelease?'
3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:28:in `version'
2: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `from_symbol'
1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `fetch'
/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `block in from_symbol': unknown or unsupported macOS version: :dunno (MacOSVersionError)
Traceback (most recent call last):
11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>'
10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
9: from /usr/local/Homebrew/Library/Homebrew/global.rb:80: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:7:in `<top (required)>'
5: from /usr/local/Homebrew/Library/Homebrew/os.rb:43:in `<module:OS>'
4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:65:in `prerelease?'
3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:28:in `version'
2: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `from_symbol'
1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `fetch'
/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:32:in `block in from_symbol': unknown or unsupported macOS version: :dunno (MacOSVersionError)
解决办法:
vim打开这个文件/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb
在这个位置 加入:monterey: "12",
shell
SYMBOLS = {
19 monterey: "12",
20 big_sur: "11",
21 catalina: "10.15",
22 mojave: "10.14",
23 high_sierra: "10.13",
24 sierra: "10.12",
25 el_capitan: "10.11",
26 yosemite: "10.10",
27 }.freeze
SYMBOLS = {
19 monterey: "12",
20 big_sur: "11",
21 catalina: "10.15",
22 mojave: "10.14",
23 high_sierra: "10.13",
24 sierra: "10.12",
25 el_capitan: "10.11",
26 yosemite: "10.10",
27 }.freeze
完整的rd文件
# typed: true
# frozen_string_literal: true
require "exceptions"
require "hardware"
require "version"
module OS
module Mac
# A macOS version.
#
# @api private
class Version < ::Version
extend T::Sig
attr_reader :arch
SYMBOLS = {
monterey: "12",
big_sur: "11",
catalina: "10.15",
mojave: "10.14",
high_sierra: "10.13",
sierra: "10.12",
el_capitan: "10.11",
yosemite: "10.10",
}.freeze
sig { params(sym: Symbol).returns(T.attached_class) }
def self.from_symbol(sym)
version, arch = version_arch(sym)
version ||= sym
str = SYMBOLS.fetch(version.to_sym) { raise MacOSVersionError, sym }
new(str, arch: arch)
end
sig { params(value: T.any(String, Symbol)).returns(T::Array[String]) }
def self.version_arch(value)
@all_archs_regex ||= begin
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
/^((#{Regexp.union(all_archs)})_)?([\w.]+)(-(#{Regexp.union(all_archs)}))?$/
end
match = @all_archs_regex.match(value)
return [] unless match
version = match[3]
arch = match[2] || match[5]
[version, arch]
end
sig { params(value: T.nilable(String), arch: T.nilable(String)).void }
def initialize(value, arch: nil)
version, arch = Version.version_arch(value) if value.present? && arch.nil?
version ||= value
arch ||= "intel"
raise MacOSVersionError, version unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(version)
super(version)
@arch = arch.to_sym
@comparison_cache = {}
end
def <=>(other)
@comparison_cache.fetch(other) do
if SYMBOLS.key?(other) && to_sym == other
0
else
v = SYMBOLS.fetch(other) { other.to_s }
@comparison_cache[other] = super(::Version.new(v))
end
end
end
sig { returns(Symbol) }
def to_sym
@to_sym ||= begin
# Big Sur is 11.x but Catalina is 10.15.
major_macos = if major >= 11
major
else
major_minor
end.to_s
SYMBOLS.invert.fetch(major_macos, :dunno)
end
end
sig { returns(String) }
def pretty_name
@pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
end
# For {OS::Mac::Version} compatibility.
sig { returns(T::Boolean) }
def requires_nehalem_cpu?
unless Hardware::CPU.intel?
raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
end
Hardware.oldest_cpu(self) == :nehalem
end
# https://en.wikipedia.org/wiki/Nehalem_(microarchitecture)
# Ensure any extra methods are also added to version/null.rb
alias requires_sse4? requires_nehalem_cpu?
alias requires_sse41? requires_nehalem_cpu?
alias requires_sse42? requires_nehalem_cpu?
alias requires_popcnt? requires_nehalem_cpu?
end
end
end
# typed: true
# frozen_string_literal: true
require "exceptions"
require "hardware"
require "version"
module OS
module Mac
# A macOS version.
#
# @api private
class Version < ::Version
extend T::Sig
attr_reader :arch
SYMBOLS = {
monterey: "12",
big_sur: "11",
catalina: "10.15",
mojave: "10.14",
high_sierra: "10.13",
sierra: "10.12",
el_capitan: "10.11",
yosemite: "10.10",
}.freeze
sig { params(sym: Symbol).returns(T.attached_class) }
def self.from_symbol(sym)
version, arch = version_arch(sym)
version ||= sym
str = SYMBOLS.fetch(version.to_sym) { raise MacOSVersionError, sym }
new(str, arch: arch)
end
sig { params(value: T.any(String, Symbol)).returns(T::Array[String]) }
def self.version_arch(value)
@all_archs_regex ||= begin
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
/^((#{Regexp.union(all_archs)})_)?([\w.]+)(-(#{Regexp.union(all_archs)}))?$/
end
match = @all_archs_regex.match(value)
return [] unless match
version = match[3]
arch = match[2] || match[5]
[version, arch]
end
sig { params(value: T.nilable(String), arch: T.nilable(String)).void }
def initialize(value, arch: nil)
version, arch = Version.version_arch(value) if value.present? && arch.nil?
version ||= value
arch ||= "intel"
raise MacOSVersionError, version unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(version)
super(version)
@arch = arch.to_sym
@comparison_cache = {}
end
def <=>(other)
@comparison_cache.fetch(other) do
if SYMBOLS.key?(other) && to_sym == other
0
else
v = SYMBOLS.fetch(other) { other.to_s }
@comparison_cache[other] = super(::Version.new(v))
end
end
end
sig { returns(Symbol) }
def to_sym
@to_sym ||= begin
# Big Sur is 11.x but Catalina is 10.15.
major_macos = if major >= 11
major
else
major_minor
end.to_s
SYMBOLS.invert.fetch(major_macos, :dunno)
end
end
sig { returns(String) }
def pretty_name
@pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
end
# For {OS::Mac::Version} compatibility.
sig { returns(T::Boolean) }
def requires_nehalem_cpu?
unless Hardware::CPU.intel?
raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
end
Hardware.oldest_cpu(self) == :nehalem
end
# https://en.wikipedia.org/wiki/Nehalem_(microarchitecture)
# Ensure any extra methods are also added to version/null.rb
alias requires_sse4? requires_nehalem_cpu?
alias requires_sse41? requires_nehalem_cpu?
alias requires_sse42? requires_nehalem_cpu?
alias requires_popcnt? requires_nehalem_cpu?
end
end
end
特别注意/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb
这个文件一定要设为只读,否则无效。