brew: Upgrade or installation should stop if command line developer tools are missing

Provide a detailed description of the proposed feature

After upgrading to Monterey 12.6 a couple of days ago I just ran brew upgrade and got into a mess with multiple packages being removed that were scheduled for update. The reason seems to be a missing xcode CLI tools update that many packages required for the installation. The upgrade process never the less continued to remove the old version although the new version failed to install.

==> Upgrading node
  18.8.0 -> 18.9.0

==> Pouring node--18.9.0.monterey.bottle.tar.gz
2022-09-14 10:19:29.179 xcodebuild[11721:1312411] [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-14 10:19:29.263 xcodebuild[11721:1312411] [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: 0x600001187de0>
Method:   -loadAssertingOnError:error:
Thread:   <_NSMainThread: 0x6000035d0440>{number = 1, name = main}
Hints:

Backtrace:
  0  0x000000010c327f81
  1  0x000000010c3274b5
  2  0x000000010c3276c1
  3  0x000000010c19e3ba
  4  0x000000010c159c73
  5  0x000000010c157a1f
  6  0x00007ff81f399317
  7  0x00007ff81f3a67ee
  8  0x000000010c3765a1
  9  0x000000010c34c0d8
 10  0x000000010c1578a3
 11  0x000000010c157af5
 12  0x000000010d23cf66
 13  0x000000010d23c526
 14  0x000000010d23b919
 15  0x000000010abc49a4
 16  0x000000010a94720a
sh: line 1: 11723 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 clang 2> /dev/null
clang: 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 clang 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)
xcode-select: Failed to locate 'clang', requesting installation of command line developer tools.
🍺  /usr/local/Cellar/node/18.9.0: 1,997 files, 49.7MB
==> Running `brew cleanup node`...
Removing: /usr/local/Cellar/node/18.8.0... (1,984 files, 49.7MB)
Removing: /Users/msa/Library/Caches/Homebrew/node--18.8.0... (13.2MB)

What is the motivation for the feature?

Failed upgrades of packages should not trigger removal of old version making the system useless.

How will the feature be relevant to at least 90% of Homebrew users?

Many users will upgrade their OS but not think about upgrading xcode propely.

What alternatives to the feature have been considered?

brew upgrade should trigger installation of the CLI tools, not an individual package.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 24 (10 by maintainers)

Most upvoted comments

xcodebuild -runFirstLaunch can fix it.

We should probably detect this state and tell the user to run xcodebuild -runFirstLaunch

This doesn’t address the fact that the alternative brew suggests (compiling from source) isn’t supported for some reason in cases where the OS thinks the tools aren’t installed although they clearly are.

They are not. The Xcode CLT and the CLT installed by xcode-select --install are not the same thing and we often need the latter, even if you have Xcode installed.

I encountered the same issue after Xcode was auto updated by App Store.