安装好多年后,iTerm2 突然开始要求我重新安装 git?

安装好多年后,iTerm2 突然开始要求我重新安装 git?

突然之间,git当我git status在终端(iTerm2)中输入时,我的 Macbook Air(OS 12.5.1 Monterey)就开始要求我安装......

如果我说“不,我不想安装 git”,则会出现以下错误消息:

$ git status
2022-09-21 18:44:57.936 xcodebuild[827:8036] [MT] DVTPlugInLoading: Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin), error = Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}, dyldError = dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0000): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'
2022-09-21 18:44:58.157 xcodebuild[827:8036] [MT] DVTAssertions: ASSERTION FAILURE in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot2/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-21303/DVTFoundation/PlugInArchitecture/DataModel/DVTPlugIn.m:374
Details:  Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin)
Please ensure Xcode packages are up-to-date — try running 'xcodebuild -runFirstLaunch'.

NSBundle error: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}
Object:   <DVTPlugIn: 0x600000c70460>
Method:   -loadAssertingOnError:error:
Thread:   <_NSMainThread: 0x600002824140>{number = 1, name = main}
Hints:

Backtrace:
  0  0x000000010c315f81
  1  0x000000010c3154b5
  2  0x000000010c3156c1
  3  0x000000010c18c3ba
  4  0x000000010c147c73
  5  0x000000010c145a1f
  6  0x00007ff81e2a0317
  7  0x00007ff81e2ad7ee
  8  0x000000010c3645a1
  9  0x000000010c33a0d8
10  0x000000010c1458a3
11  0x000000010c145af5
12  0x000000010d22af66
13  0x000000010d22a526
14  0x000000010d229919
15  0x000000010abb29a4
16  0x000000010a93520a
sh: line 1:   848 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.

PS,我刚刚说“是”安装 git,大约花了 30 分钟,现在它又要求安装它了!我只是为了以防万一重启了电脑,但如果我说“否”,它仍然会抛出相同的消息和错误。

以下是两张截图:

在此处输入图片描述 在此处输入图片描述

为什么这种情况会突然随机发生,有什么解决方法吗?我有一段时间没有下载任何东西了,而且我很确定操作系统今天没有自动更新。也许是 iTerm2 更新了什么的……不,我尝试git status在实用程序 > 终端应用程序中运行,结果还是一样……

只是为了澄清一下,git status一直在努力多年在我的 Macbook Air 上,我最近没有更改任何内容。所以发生了一些奇怪的事情。我的硬盘上还有 85GB 的空间,所以我认为这不是空间问题......

答案1

当 Xcode 安装git为 时/usr/bin/git,它实际上只是一个小的存根二进制文件,它会调用xcodebuild来查找并执行git深埋在/Applications/Xcode.app包中的真正二进制文件。如果您的 Xcode 安装出现问题,此技巧就会失效。

如果您从 App Store 安装了 Xcode,它可能刚刚自动更新到 Xcode 14,该版本上周刚刚与 iOS 16 一起发布。Xcode 14 可能有一份新的许可协议,需要先确认才能运行任何与 Xcode 相关的程序。或者它可能发生了其他一些变化(可能是它调用与 Xcode 相关的命令行工具的方式),而这些变化可能会在 Xcode 的首次运行初始化过程中得到修复。

如果您不使用或不关心 Xcode,并且想要一个git与 Xcode 不绑定的版本,请git通过 Homebrew 或其他方式安装您自己的副本,并使用它来代替 Xcode 安装的/usr/bin/git

顺便说一句,这与 iTerm2 无关。您可能在 macOS 的内置终端应用中遇到同样的问题。您发布的错误消息全部来自 Xcode 的部分内容(以及 Xcode 的一个片段执行的一次 Bourne shell 调用)。

相关内容