Repository navigation
Homebrew cask launcher asks for AZ_PYTHON when the Homebrew prefix is a symlink #34187
Description
Activity
- addedcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.
on Oct 8, 2026 Thank you for opening this issue, we will look into it.
- addedAzure CLI TeamThe command of the issue is owned by Azure CLI teamThe command of the issue is owned by Azure CLI team
on Oct 8, 2026 - addedRequest X Engineering AgentRequest X Engineering Agent testing and reviewRequest X Engineering Agent testing and review
on Oct 8, 2026 x-engineering-agent commented
on Oct 8, 2026 ContributorMore actionsBug Analysis
Affected area: Homebrew cask / standalone packaging in
Azure/azure-cli, target branchdev. Target inference found no command module or extension; this is repository-owned launcher code, not an extensions-repository issue.Use this EXACT PR title:
[Packaging] Fix #34187:az version: Detect Homebrew casks with symlinked prefixesReported reproduction and expected result
Azure CLI 2.91.0 installed as a Homebrew cask, Homebrew 7.0.8, macOS 27 on Apple silicon. With the Homebrew prefix symlinked to a relocated directory, install the cask and invoke
az versionwithoutAZ_PYTHON. The reporter observesError: AZ_PYTHON not set.and the offline/tarball Python instruction, despite Homebrewpython@3.14being installed. The expected result is cask detection and use of the cask's Homebrew Python without requiringAZ_PYTHON.The issue supplies the exact command, error, expected behavior, versions and reproduction steps. No additional reporter information is blocking. Similar-issue lookup returned no candidates. This is source-supported analysis, not a locally executed reproduction.
Current source evidence
Inspected
devatfec1915074bb57bfcf40961fe0b982c1c96d7848:templates/az_launcher.sh.inresolves launcher symlinks using physical directories, but classifies casks using three literal Homebrew prefixes. A resolved relocated prefix falls through toINSTALLER=TARBALL, which explains the reportedAZ_PYTHONerror.- The same launcher searches for Python only under those fixed prefixes. Broadening cask recognition alone is insufficient for a custom physical prefix: interpreter discovery must use the corresponding actual Homebrew installation too.
build_binary_tar_gz.pyrenders the launcher from that.intemplate in_create_launcher_script, uses Python version3.14by default and substitutesPYTHON_BIN=python3. Its build-timefind_homebrew_pythonalready uses the formula'slibexec/bin/pythoncandidate. The install structure createsbin/azas a relative link to../libexec/bin/az.templates/azure-cli.rb.indeclares the versioned Homebrew Python formula dependency and installsbin/azas the cask binary.
Requirements for the fix
- Fix cask recognition and Python discovery in the authoritative standalone launcher template for both symlinked standard prefixes and custom/relocated prefixes. Associate the interpreter with the detected Homebrew installation; do not select an unrelated installation or require an environment variable that ordinary cask invocation does not provide. Preserve quoting and macOS-compatible shell/path behavior.
- Keep the change scoped to launcher packaging and directly related regression coverage. Account for the formula's actual interpreter layout rather than relying solely on the nonexistent
libexec/bin/python3candidate; preserve working versioned-interpreter fallbacks. - Preserve genuine offline/tarball behavior: outside a cask installation, require and honor explicit
AZ_PYTHON, including existing missing/non-executable diagnostics. Preserve argument forwarding,AZ_INSTALLER,PYTHONPATH, package-location validation and supported standard-prefix behavior. - Add focused regression coverage using repository test conventions and a rendered launcher. Cover a physically relocated prefix reached through symlinks, a custom prefix, the relative
bin/azlink, default-prefix behavior, versioned/formula Python lookup, missing Python, and non-cask execution with and withoutAZ_PYTHON. Include quoted paths with spaces. Use isolated fixtures, not mutations of a developer's Homebrew installation. In the implementation job, run the applicable existing validation and report actual results; do not claim macOS or live validation that was not performed. - Edit the source template, not a generated release launcher, tarball or generated cask artifact.
build_binary_tar_gz.pyis the verified renderer; use the real renderer for coverage where appropriate. No AAZ-generated command code is involved or needs modification. Do not expand the fix into AAZ output. If an AAZ dependency is discovered, report the blocker and require the governed durableAzure/aazsource-PR/generation workflow rather than directly editing generated files.
PR title & description format (required)
This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.
Use this EXACT PR title (copy verbatim, do not reword):
[Packaging] Fix #34187: `az version`: Detect Homebrew casks with symlinked prefixesKeep the backticks around the command and the
Fix #34187:prefix. You may only adjust the wording after the command (the final summary) if the fix changes; the[Packaging]prefix, issue link, and backticked command must stay.Description — follow the PR template and fill in:
- Link the issue — start the Description with a closing keyword so the PR auto-links and closes it:
Fixes #34187. - Related command — the
az ...command this affects. - Description (mandatory) — why the bug happens, what you changed, and the resulting behavior.
- Testing Guide — example command(s) showing the fix works.
- History Notes — leave the title to drive the history note, or add extra lines in the same format (component in brackets + the command in backticks), e.g.
[Packaging] `az <command>`: <note>. - Keep the template checklist and tick the items you've satisfied.
Posted by x-engineering-agent (Fixer)
- removedRequest X Engineering AgentRequest X Engineering Agent testing and reviewRequest X Engineering Agent testing and review
on Oct 8, 2026
Describe the bug
With the new Homebrew cask (
brew install --cask azure-cli, 2.91.0),azfails on a Mac where the Homebrew prefix is a symlink (here/opt/homebrew -> /private/.bulk/opt/homebrew, which itself resolves to another volume):Cause:
scripts/release/standalone/templates/az_launcher.sh.inresolves its own path withcd -P(physical), then compares the result against literal prefixes:bash -xshows the resolved path is/Volumes/Data/.bulk/opt/homebrew/Caskroom/azure-cli/2.91.0/bin/../libexec/bin/az, soINSTALLER=TARBALLand the launcher demandsAZ_PYTHON, even though it is a cask install andpython@3.14is installed. The same happens with any custom Homebrew prefix.To reproduce
brew install --cask azure-cliaz versionExpected behavior
The cask install is detected and uses Homebrew's
python@3.14, with noAZ_PYTHONneeded.Suggestions
*/Caskroom/azure-cli/*. Or compare against the physical path of$HOMEBREW_PREFIX, orbrew --prefix.opt/python@3.14/libexec/bin/python3, doesn't exist in Homebrew'spython@3.14(itslibexec/binhaspython, notpython3). Detection only works because of thebin/python3.14fallback.Workaround
export AZ_PYTHON="$HOMEBREW_PREFIX/opt/python@3.14/bin/python3.14"Environment
/opt/homebrew, a symlink to/private/.bulk/opt/homebrew