Homebrewが古くなっていたので再インストールしたら躓いた件

# Homebrewインストールしようとするものの...
最近は仮想環境上で構築することが多かったが、mac OSを使うにあたりHomebrewをインストールしようとすると、下記の警告が出た。

```ruby
brew install git
Updating Homebrew...

Warning: You are using macOS 12.5.
We do not provide support for this pre-release version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this pre-release version.
```

`brew doctor`で問題チェックしてみる。

```ruby
brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install


Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
/usr/local/include/node/cppgc/allocation.h
などの/usr/local/include/配下のファイル名


Warning: You are using macOS 12.5.
We do not provide support for this pre-release version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this pre-release version.


Warning: Could not find an SDK that supports macOS 12.5.
You may have have an outdated or incompatible Xcode.

Please update Xcode or uninstall it if no updates are available.
```
# アンインストール

https://qiita.com/mashi0727/items/a7e63dc3d2e6fed7ac19

上記手順のコマンドを試してみる。

```ruby
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
```

```ruby
Error: The Ruby Homebrew uninstaller is now disabled and has been rewritten in
Bash. Please migrate to the following command:
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
```
今は使えないようなので、エラーででたアンインストールコマンドを使用する。

```ruby
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
ユーザー配下のファイル名
```

`Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y`
Homebrewをアンインストールするか聞いてくるので、問題なければyをする。
`Homebrew uninstalled!`が出たことを確認する。

# インストールを試みるが...
改めてインストールしてみる。
```ruby
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```


```ruby
Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core 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!
Failed during: /usr/local/bin/brew update --force --quiet
```
エラー文に`unshallow`コマンドが求められているので試してみる。
`unshallow`コマンドについては下記の記事に書かれている。

https://web-y.dev/2021/05/23/mac-brew-update-unshallow/

```ruby
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
```
# ファイル消去
`brew doctor`で再び状況確認してみる。

```ruby
brew doctor

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
/usr/local/include/配下のファイル名
```

https://qiita.com/rinimaruranran/items/2d8d930ad846fa41b9e6

上記の記事をもとにフォルダごとを消す。

```ruby
sudo rm -R /usr/local/include/node
```

```ruby
brew doctor
Your system is ready to brew.
```
やっと土壌が整ったようだ。

# brew update

```ruby
git fetch --unshallow
fatal: not a git repository (or any of the parent directories): .git
```

https://qiita.com/gosairei1207/items/701b7ae494b96db0f9a1

`git fetch`しようとしたが上手くいかなったので、上記手順をもとに`git init`を行う。

```ruby
git init
Initialized empty Git repository in 作業ディレクトリ/.git/
```
初期化できた模様。

```ruby
git fetch --unshallow
fatal: --unshallow on a complete repository does not make sense
```

https://qiita.com/jintz/items/b2a80590531c373bae39

上記記事をもとに、最後のメッセージから`unshallow`に問題ないことがわかった。
`brew update`したら問題なくアップデートできた。

```ruby
brew update
Updated 2 taps (homebrew/core and homebrew/services).
```