macOS Montereyに移行して、XcodeをインストールしてからHomebrewをインストールしようとすると以下のエラーが...
sh: line 1: 11955 Abort trap: 6 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find git 2> /dev/null
git: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find git 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)
xcode-select: Failed to locate 'git', requesting installation of command line developer tools.
おまけに入れたはずのXcode command line toolsのインストールを要求され、それに従ってインストールを行い、それが終了した後にHombrewのインストールを試すと、同じメッセージとXcde command line toolsインストールの繰り返しの無限ループにハマりました。
ググったところ、以下のスレッドで解決方法が紹介されていました。
以下のコマンドを実行してパスを切り替えると良いようです。
sudo xcode-select -switch /Library/Developer/CommandLineTools
これでHombrewのインストールを行うことができました。