From 764d2b2dcc6efdb57123acae01eb7148883d7ff4 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:36:30 -0400 Subject: [PATCH] Add HOMEBREW_MACOS_NEWEST_SUPPORTED env var We have a `HOMEBREW_MACOS_NEWEST_UNSUPPORTED` environment variable and this is used in `MacOSVersion` to determine prerelease versions but we don't have a way of easily determining the newest supported macOS version. `bump-cask-pr` contains logic that assumes the first key/value in `MacOSVersion::SYMBOLS` is the newest macOS version but it recently became clear that this is a prerelease version between WWDC and the subsequent macOS release. Similarly, `dev-cmd/generate-cask-api.rb` tries to compute the newest stable macOS version as `HOMEBREW_MACOS_NEWEST_UNSUPPORTED.to_i - 1` and this will fail if/when we update that variable to `"26"`, as the macOS version before 26 is 15, not 25. This adds a `HOMEBREW_MACOS_NEWEST_SUPPORTED` environment variable, so we have a straightforward way of quickly identifying the newest supported macOS version without having to make potentially unreliable assumptions or do computations to identify the latest non-prerelease `MacOSVersion` value. This also updates the two aforementioned areas to use this environment variable to produce the newest stable macOS version symbol in a more reliable way. --- Library/Homebrew/brew.sh | 3 +++ Library/Homebrew/dev-cmd/bump-cask-pr.rb | 2 +- Library/Homebrew/dev-cmd/generate-cask-api.rb | 2 +- Library/Homebrew/global.rb | 1 + Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 537ee55a4e..3557d8a40b 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -614,6 +614,8 @@ esac # and, if needed: # - MacOSVersion::SYMBOLS HOMEBREW_MACOS_NEWEST_UNSUPPORTED="16" +# TODO: bump version when new macOS is released +HOMEBREW_MACOS_NEWEST_SUPPORTED="15" # TODO: bump version when new macOS is released and update references in: # - docs/Installation.md # - HOMEBREW_MACOS_OLDEST_SUPPORTED in .github/workflows/pkg-installer.yml @@ -841,6 +843,7 @@ export HOMEBREW_OS_VERSION export HOMEBREW_MACOS_VERSION export HOMEBREW_MACOS_VERSION_NUMERIC export HOMEBREW_MACOS_NEWEST_UNSUPPORTED +export HOMEBREW_MACOS_NEWEST_SUPPORTED export HOMEBREW_MACOS_OLDEST_SUPPORTED export HOMEBREW_MACOS_OLDEST_ALLOWED export HOMEBREW_USER_AGENT diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index 72e20c132e..e7ce29cc99 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -190,7 +190,7 @@ module Homebrew def generate_system_options(cask) current_os = Homebrew::SimulateSystem.current_os current_os_is_macos = MacOSVersion::SYMBOLS.include?(current_os) - newest_macos = MacOSVersion::SYMBOLS.keys.first + newest_macos = MacOSVersion.new(HOMEBREW_MACOS_NEWEST_SUPPORTED).to_sym depends_on_archs = cask.depends_on.arch&.filter_map { |arch| arch[:type] }&.uniq diff --git a/Library/Homebrew/dev-cmd/generate-cask-api.rb b/Library/Homebrew/dev-cmd/generate-cask-api.rb index 9f639aec52..11922c7212 100644 --- a/Library/Homebrew/dev-cmd/generate-cask-api.rb +++ b/Library/Homebrew/dev-cmd/generate-cask-api.rb @@ -45,7 +45,7 @@ module Homebrew Cask::Cask.generating_hash! all_casks = {} - latest_macos = MacOSVersion.new((HOMEBREW_MACOS_NEWEST_UNSUPPORTED.to_i - 1).to_s).to_sym + latest_macos = MacOSVersion.new(HOMEBREW_MACOS_NEWEST_SUPPORTED).to_sym Homebrew::SimulateSystem.with(os: latest_macos, arch: :arm) do tap.cask_files.each do |path| cask = Cask::CaskLoader.load(path) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index ff9d0f79b3..46dac9b308 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -51,6 +51,7 @@ HOMEBREW_HOME_PLACEHOLDER = "/$HOME" HOMEBREW_CASK_APPDIR_PLACEHOLDER = "$APPDIR" HOMEBREW_MACOS_NEWEST_UNSUPPORTED = ENV.fetch("HOMEBREW_MACOS_NEWEST_UNSUPPORTED").freeze +HOMEBREW_MACOS_NEWEST_SUPPORTED = ENV.fetch("HOMEBREW_MACOS_NEWEST_SUPPORTED").freeze HOMEBREW_MACOS_OLDEST_SUPPORTED = ENV.fetch("HOMEBREW_MACOS_OLDEST_SUPPORTED").freeze HOMEBREW_MACOS_OLDEST_ALLOWED = ENV.fetch("HOMEBREW_MACOS_OLDEST_ALLOWED").freeze diff --git a/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb b/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb index 2152491e82..5d78ee310f 100644 --- a/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb @@ -6,7 +6,7 @@ require "dev-cmd/bump-cask-pr" RSpec.describe Homebrew::DevCmd::BumpCaskPr do subject(:bump_cask_pr) { described_class.new(["test"]) } - let(:newest_macos) { MacOSVersion::SYMBOLS.keys.first } + let(:newest_macos) { MacOSVersion.new(HOMEBREW_MACOS_NEWEST_SUPPORTED).to_sym } let(:c) do Cask::Cask.new("test") do