Improve brew doctor output on prerelease macOS

- Avoid near duplicate messages
- Provide correct CLT download instructions

Before:
```
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Your Command Line Tools are too outdated.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 16.0.

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 16.0.

Warning: Your Xcode (15.4) at /Applications/Xcode.app is too outdated.
Please update to Xcode 16.0 (or delete it).
Xcode can be updated from:
  https://developer.apple.com/download/all/

Warning: Your Xcode (15.4) is outdated.
Please update to Xcode 16.0 (or delete it).
Xcode can be updated from:
  https://developer.apple.com/download/all/

If 16.0 is installed, you may need to:
  sudo xcode-select --switch /Applications/Xcode.app
Current developer directory is:
  /Applications/Xcode.app/Contents/Developer

```

After:
```console
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Your Command Line Tools are too outdated.
Install the Command Line Tools for Xcode 16 from:
  https://developer.apple.com/download/all/

Warning: Your Xcode (15.4) at /Applications/Xcode.app is too outdated.
Please update to Xcode 16.0 (or delete it).
Xcode can be updated from:
  https://developer.apple.com/download/all/

```
This commit is contained in:
Mike McQuaid 2024-09-06 17:36:27 +01:00
parent b5114360d8
commit dc9618457d
No known key found for this signature in database
2 changed files with 13 additions and 0 deletions

View File

@ -130,6 +130,9 @@ module Homebrew
def check_xcode_up_to_date def check_xcode_up_to_date
return unless MacOS::Xcode.outdated? return unless MacOS::Xcode.outdated?
# avoid duplicate very similar messages
return if MacOS::Xcode.below_minimum_version?
# CI images are going to end up outdated so don't complain when # CI images are going to end up outdated so don't complain when
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
# repository. This only needs to support whatever CI providers # repository. This only needs to support whatever CI providers
@ -161,6 +164,9 @@ module Homebrew
def check_clt_up_to_date def check_clt_up_to_date
return unless MacOS::CLT.outdated? return unless MacOS::CLT.outdated?
# avoid duplicate very similar messages
return if MacOS::CLT.below_minimum_version?
# CI images are going to end up outdated so don't complain when # CI images are going to end up outdated so don't complain when
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
# repository. This only needs to support whatever CI providers # repository. This only needs to support whatever CI providers

View File

@ -315,6 +315,11 @@ module OS
Install the Command Line Tools for Xcode 11.3.1 from: Install the Command Line Tools for Xcode 11.3.1 from:
#{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)} #{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)}
EOS EOS
elsif OS::Mac.version.prerelease?
<<~EOS
Install the Command Line Tools for Xcode #{minimum_version.split(".").first} from:
#{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)}
EOS
else else
<<~EOS <<~EOS
Install the Command Line Tools: Install the Command Line Tools:
@ -325,6 +330,8 @@ module OS
sig { returns(String) } sig { returns(String) }
def self.update_instructions def self.update_instructions
return installation_instructions if OS::Mac.version.prerelease?
software_update_location = if MacOS.version >= "13" software_update_location = if MacOS.version >= "13"
"System Settings" "System Settings"
elsif MacOS.version >= "10.14" elsif MacOS.version >= "10.14"