From 2feea851a993e5e188f2bee201a768dfdfa06738 Mon Sep 17 00:00:00 2001 From: Yang An Date: Thu, 25 Jun 2026 12:29:51 +1000 Subject: [PATCH] {Packaging} Fix Homebrew test install on older brew by rewriting formula_opt_prefix in test jobs The macOS CI jobs fail with NoMethodError undefined method formula_opt_prefix during brew install. Upstream homebrew-core azure-cli.rb now uses the newer formula_opt_prefix DSL helper, absent on the older Homebrew on the macOS-14 agent image. Following the existing no_autobump convention, patch the formula only in the test jobs right before brew install via sed, rewriting it to the backward-compatible Formula opt_prefix form. The generated and submitted formula stays upstream-faithful. --- azure-pipelines.yml | 6 ++++++ scripts/release/homebrew/test_homebrew_package.sh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 213883b22d2..37253370022 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -683,6 +683,12 @@ jobs: # allowed in official Homebrew taps. Remove it so the formula can be installed from # this local dev tap. It must remain in the released formula, so we only strip it here. sed -i '' '/no_autobump!/d' $(brew --repository)/Library/Taps/dev/homebrew-azure-cli/Formula/azure-cli.rb + # TODO(packaging): remove once the macOS CI agent image's Homebrew provides formula_opt_prefix. + # The upstream homebrew-core formula calls `formula_opt_prefix("openssl@3")`, a newer + # Homebrew DSL helper not available on the older Homebrew on the macOS CI agent image + # (NoMethodError). Rewrite it to the backward-compatible `Formula["openssl@3"].opt_prefix` + # form for the local test install only; the generated/submitted formula stays upstream-faithful. + sed -E -i '' 's/formula_opt_prefix\(?[[:space:]]*"([^"]+)"[[:space:]]*\)?/Formula["\1"].opt_prefix/g' $(brew --repository)/Library/Taps/dev/homebrew-azure-cli/Formula/azure-cli.rb brew install --build-from-source dev/homebrew-azure-cli/azure-cli echo == Az Version == diff --git a/scripts/release/homebrew/test_homebrew_package.sh b/scripts/release/homebrew/test_homebrew_package.sh index f55d9ab5074..c0471691cef 100755 --- a/scripts/release/homebrew/test_homebrew_package.sh +++ b/scripts/release/homebrew/test_homebrew_package.sh @@ -8,6 +8,12 @@ echo == Remove pre-installed azure-cli == brew uninstall azure-cli echo == Install azure-cli.rb formula == +# TODO(packaging): remove once the macOS CI agent image's Homebrew provides formula_opt_prefix. +# The upstream homebrew-core formula calls `formula_opt_prefix("openssl@3")`, a newer +# Homebrew DSL helper not available on the older Homebrew on the macOS CI agent image +# (NoMethodError). Rewrite it to the backward-compatible `Formula["openssl@3"].opt_prefix` +# form for the local test install only; the generated/submitted formula stays upstream-faithful. +sed -E -i '' 's/formula_opt_prefix\(?[[:space:]]*"([^"]+)"[[:space:]]*\)?/Formula["\1"].opt_prefix/g' $SYSTEM_ARTIFACTSDIRECTORY/homebrew/azure-cli.rb brew install --build-from-source $SYSTEM_ARTIFACTSDIRECTORY/homebrew/azure-cli.rb AZ_BASE=/usr/local/Cellar/azure-cli/$CLI_VERSION/libexec