OS version: :dunno (MacOSVersionError)

f:id:tworks55:20220304084718p:plain

使っていないJMeterに対してlog4j脆弱性が検知され邪魔だったので、削除しようとしたところHomebrewでエラーが発生。

ということで解決方法をメモしておきます。

JMeterの削除に失敗した際のエラー。 unknown or unsupported macOS version: :dunno (MacOSVersionError)と記載されているのでOS Upgrade後にHomebrewの内容が更新されていないために発生しているのかもしれません。

> brew uninstall jmeter
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 /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     7: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/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:60: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:33:in `from_symbol'
     1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:33:in `fetch'
/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:33:in `block in from_symbol': unknown or unsupported macOS version: :dunno (MacOSVersionError)

Homebrewのアップデートをしてみたけど、まだエラーが発生します。

> brew update
Error: 
  homebrew-core is a shallow clone.
  homebrew-cask is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

エラーメッセージに記載されている2つのgitコマンドを実行します。少し時間がかかります。

> git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

<中略>

> git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
remote: Enumerating objects: 452796, done.
remote: Counting objects: 100% (452773/452773), done.
remote: Compressing objects: 100% (137073/137073), done.
remote: Total 445690 (delta 319247), reused 434428 (delta 308040), pack-reused 0
Receiving objects: 100% (445690/445690), 205.94 MiB | 2.40 MiB/s, done.
Resolving deltas: 100% (319247/319247), completed with 5369 local objects.
From https://github.com/Homebrew/homebrew-cask
   bdc8e24694..523656a49e  master     -> origin/master

そしてHomebrewのアップデートを再度実行。

> brew update
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
######################################################################################################## 100.0%
==> Pouring portable-ruby-2.6.8.yosemite.bottle.tar.gz
Updated 6 taps (heroku/brew, cloudfoundry/tap, homebrew/core, homebrew/cask, adoptopenjdk/openjdk and ubuntu/microk8s).
==> New Formulae
aarch64-elf-binutils                 gpg-tui                              pinot
abi-compliance-checker               gradle@6                             pip-audit
abi-dumper                           grafana-agent                        pip-tools

<中略>

masterway-note                                          yy
mathinspector                                           zbuc-imgur
mediahuman-audio-converter                              zipcleaner
mega                                                    zoolz

You have 39 outdated formulae and 4 outdated casks installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

無事にHomebrewのアップデートが完了したのでJMeterをアンインストール。

> brew uninstall jmeter
Uninstalling /usr/local/Cellar/jmeter/5.2.1... (2,625 files, 143.4MB)
> 

久しぶりにMacを使うとこんなことに遭遇しますね。