M1 Macbook(Monterey 12.2.1) 安装Qt遇到的问题记录

首先执行:

1
brew install qt

没有意外报错了,错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Running `brew update --preinstall`...
fatal: Could not resolve HEAD to a revision
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> New Casks
keysafe mixed-in-key-live wpsoffice-cn
==> Updated Casks
Updated 40 casks.

Warning: No available formula with the name "qt".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

那我就更新一下brew吧,执行:

1
brew update --preinstall

又是报错:

1
fatal: Could not resolve HEAD to a revision

应该是brew出问题了,再次用这个命令更新一下:

1
brew update --verbose

孩她妈报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Checking if we need to fetch /opt/homebrew...
Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /opt/homebrew...
Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core...
Updating /opt/homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

Updating /opt/homebrew/Library/Taps/homebrew/homebrew-core...
fatal: Could not resolve HEAD to a revision

Already up-to-date.

但至少信息详细了点,注意看Updating /opt/homebrew/Library/Taps/homebrew/homebrew-core...,于是我们,进入这个目录,执行下面的命令

1
cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
1
git fetch --prune origin
1
git pull --rebase origin master

命令都执行完后,在更新brew就易如反掌了,最后顺利安装Qt

1
brew update
1
brew install qt