Skip to content

scripts/prereqs-macos.sh

Platforms: macOS.

Purpose

prereqs-macos.sh installs command-line tools on a Mac with Homebrew: the Xcode Command Line Tools, Python 3.12+, Git and the Azure CLI. It is optional. setup.sh needs only Python 3.12 or later, and offers to install its own private Azure CLI when there is none, so this script is a convenient way to get Python, not a required step.

Microsoft's Agent 365 CLI (a365), the .NET SDK it runs on, and PowerShell 7 are no longer installed by default: setup switches on Word, Excel and OneDrive files by itself, without them. --with-a365-cli installs them anyway, for using the Agent 365 CLI yourself.

It is safe to re-run; each step detects an existing install and skips straight to the next one.

Requirements

  • macOS only. The script checks uname -s for Darwin and exits 1 on any other platform, pointing Linux users at their package manager and Windows users at prereqs-windows.ps1.
  • Homebrew must already be installed. The script does not install Homebrew itself — Homebrew's own installer needs sudo and an interactive EULA acceptance, which this script cannot safely automate. If brew is not on PATH (checking both the Apple Silicon and Intel prefixes), it prints the official install command and exits 1.
  • A working internet connection for Homebrew downloads.

Usage

# What setup can use: Xcode Command Line Tools, Python 3.12+, Git, Azure CLI
./scripts/prereqs-macos.sh

# Also the .NET SDK, Microsoft's Agent 365 CLI and PowerShell 7
./scripts/prereqs-macos.sh --with-a365-cli

Options

  • --with-a365-cli — also install the .NET SDK, the Microsoft Agent 365 DevTools CLI (a365) and PowerShell 7+. Setup does not need any of them.
  • --core-only, --skip-a365, --skip-pwsh — still accepted. They leave out the .NET SDK and a365 (--skip-a365), PowerShell 7 (--skip-pwsh), or both (--core-only), which is now the default. Given after --with-a365-cli, they leave those parts out again.
  • -h, --help — print the script's header comment as usage text and exit 0.
  • Any unrecognized argument prints ERROR: Unknown argument: <arg> to stderr, then falls through to the same help text as --help and exits 0 — it does not abort with a non-zero status.

Effects

  1. Verifies macOS and resolves the Homebrew prefix (/opt/homebrew or /usr/local), exporting it onto PATH for the rest of the run if not already present.
  2. Xcode Command Line Tools — if not already installed (xcode-select -p), triggers xcode-select --install, which opens a system dialog. This step is interactive: the script prints a prompt and blocks on read until the operator accepts the dialog and presses Enter.
  3. Python 3.12+ — probes python3.13, python3.12, then python3 for a version ≥ 3.12; installs python@3.12 via Homebrew if none qualify.
  4. Git — installs via Homebrew only if no git is already on PATH (Xcode CLT usually provides one).
  5. Azure CLI — installs azure-cli via Homebrew if az is missing. Setup uses an az on PATH when there is one.
  6. .NET SDK + a365 (only with --with-a365-cli) — installs the dotnet Homebrew formula, then installs or updates the Microsoft Agent 365 DevTools CLI as a global .NET tool, adding ~/.dotnet/tools to PATH for the rest of the run. Without the option, it prints that it is not installed because setup does not need it.
  7. PowerShell 7+ (only with --with-a365-cli) — installs the powershell Homebrew formula if pwsh is missing.
  8. Runs a final validation pass re-checking every tool it was asked to install (skipping the parts it left out) and prints a summary of what was already present, newly installed, and failed, then the next step: ./scripts/setup.sh.

Exit behavior

  • 0 — all requested tools are installed and confirmed on PATH, --help was requested, or an unrecognized argument was passed (help text is shown first).
  • 0 — installs all succeeded but one or more tools are not yet visible on PATH in the current shell (most commonly python3.12, or a365 right after its first install). The script warns and tells the operator to open a new terminal before running setup.sh. The validation pass looks for python3.12 by that name, so a Mac whose only new-enough Python is python3.13 also gets this warning; setup itself uses python3.13.
  • 1 — not running on macOS, Homebrew is missing, Xcode CLT installation did not complete, or any Homebrew install step failed.

Common failures

  • Homebrew not found — install it with the official one-liner printed by the script, then re-run.
  • Stuck at the Xcode CLT dialog — the system dialog can appear behind other windows; check the Dock, accept it, then return to the terminal and press Enter.
  • python3.12 not on PATH after install — open a new terminal (Homebrew changes to PATH only take effect in new shells) and re-run.
  • a365 missing after install (with --with-a365-cli) — same PATH-refresh issue for ~/.dotnet/tools; the script prints the exact export PATH line to add to ~/.zshrc if needed.