macOS Montery更新到v12.4版本之后,系统中的Git莫名其妙消失了!

714 阅读2分钟

如果着急,解决办法请看最下面!

vscode-background.jpg

莫名其妙重启的 Mac

最近电脑在我睡觉的时候莫名其妙的重启,我就探究其原因,原来是有软件要更新了,但是他自己好像没有更新成功。

看你这么认真地想要更新,那我就勉为其难去更新吧!

然后我一看,原来是macOS Montery要更新了,虽然比较大,但我还是更新了,不然每天都面临电脑重启,让我一度怀疑我的电脑是不是有病毒了。

更新的过程很顺利,但是macOS Montery更新完了之后,打开我的VScode,发现我的Git莫名其妙消失了!

哎,下载吧!

安装 Git 的艰辛

去了git官网,我选择点击 Binary installer 中的“installer”。

9C30FF04-174B-4E4D-96A5-D2A7D08229A5.png

下载完gitdmg包之后,发现他不自己安装了,我手动点击不也行了。然后我就莫名其妙选择使用MacPorts中的 sudo port install git,然后就报port不存在,又开始了安装MacPort的神奇旅程!

经过一些曲折,在这个博客上安装上了MacPorts,配好环境变量,执行sudo port -v selfupdate,发现报错了

--->  MacPorts base is outdated, installing new version 2.7.2
Error: 
Error: No Xcode installation was found.
Error: Please install Xcode and/or run xcode-select to specify its location.
Error: 
Installing new MacPorts release in /opt/local as root:wheel; permissions 0755

checking build system type... aarch64-apple-darwin21.5.0
checking host system type... aarch64-apple-darwin21.5.0
checking target system type... aarch64-apple-darwin21.5.0
checking MacPorts version... 2.7.2
checking for sw_vers... /usr/bin/sw_vers
checking for defaults... /usr/bin/defaults
checking for xcode-select... /usr/bin/xcode-select
checking macOS version... 12.4
checking Xcode location... /Library/Developer/CommandLineTools
checking whether the C compiler works... no
configure: error: in `/opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/base':
configure: error: C compiler cannot create executables
See `config.log' for more details
Command failed: CC=/usr/bin/cc ./configure --prefix=/opt/local --with-install-user=root --with-install-group=wheel --with-directory-mode=0755 --enable-readline && make SELFUPDATING=1 && make install SELFUPDATING=1
Exit code: 77
Error: Error installing new MacPorts base: command execution failed
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.
Error: /opt/local/bin/port: port selfupdate failed: Error installing new MacPorts base: command execution failed

我心里那个苦啊😭

看着意思是少了Xcode,然后我就开始执行sudo xcode-select --install,安装完xcode之后git就回来了。

查找原因

然后查了一下原因,好像是mac每次更新系统就会卸载xcode,在终端输入 xcode-select --install,重新下载 xcode,这个下载完之后输入git命令就好使了。

所以,同志们,要不你们先别经历我的路程,直接执行最后一步,看看行不行!

截屏2022-07-15 14.43.42.png