GeekCoding101 make your way to geek

Install Azure CLI on Mac: Fix Homebrew Permission Errors

brew install azure-cli failing on macOS? Fix the Homebrew OpenSSL and Python permission errors with chown and brew unlink, then verify az works.

4 min read
Install Azure Cli On Mac
On this pageWhy I needed az in the first place

If brew install azure-cli fails on your Mac with a permission error, the cause is usually Homebrew directories that your user doesn’t own. I fixed it by unlinking Homebrew’s Python and taking ownership of /usr/local with chown, after which the install finished cleanly.

Below are the exact errors I hit, the commands that worked, and how to check that az is ready to use.

Why I needed az in the first place

I was working through some good hands-on tutorials on the Microsoft website, such as the “Cloud Skills Challenge: Microsoft Build: Build multimodal Generative AI experiences”. I enjoyed the learning. But the very first step, getting the az command to work on a Mac, is where a lot of people seem to get stuck. So I wrote down every fix I needed.

The quick fix

If you just want the commands, this is what worked for me:

Terminal window
# 1. Install Azure CLI with Homebrew
brew update && brew install azure-cli
# 2. If it fails with OpenSSL / Python permission errors:
brew unlink python@3.11
sudo chown -R "$USER":admin /usr/local/
# 3. Run the install again
brew install azure-cli

The rest of this post walks through each error in the order I hit them.

Step 1: Install Azure CLI with Homebrew

I followed Microsoft’s guide for installing Azure CLI on macOS, which uses Homebrew:

Terminal window
brew update && brew install azure-cli

Step 2: OpenSSL permission error

The install failed with a permission issue on the openssl package.

Figure 1: install Azure Cli HIT Openssl Permission Issue
Figure 1: install Azure Cli HIT Openssl Permission Issue

I changed the owner of /usr/local/lib to my current user. That got past the OpenSSL error, but it wasn’t enough.

Step 3: Python permission error

Next I hit a Python permission issue in a different location under /usr/local.

Figure 2: Python Permission Issue

Fixing one folder at a time wasn’t going to work, so I unlinked the existing Homebrew Python and applied the ownership change to the whole of /usr/local:

Terminal window
brew unlink python@3.11
sudo chown -R "$USER":admin /usr/local/
Figure 3: Brew Unlink Existing Python

Step 4: Run the install again

With the permissions fixed, brew install azure-cli finished successfully.

Figure 4: azure-cli Installation Success

Step 5: Check that az works

Confirm the CLI is on your path and see the installed version:

Terminal window
az --version

Then sign in to start using it:

Terminal window
az login

Notes before you run chown

SituationWhat to do
Intel Mac (Homebrew in /usr/local)The commands above apply as written.
Apple Silicon Mac (Homebrew in /opt/homebrew)The paths differ. Check which directories the error message names before changing ownership.
You’d rather not change all of /usr/localHomebrew’s error output usually lists the exact directories it can’t write to. Try chown on just those first.
Something still looks wrongRun brew doctor to see what Homebrew reports.

sudo chown -R on all of /usr/local is a broad change. It worked for me on a machine where I’m the only user, but on a shared Mac, start with the narrower option.

FAQ

How do I install Azure CLI on a Mac? Run brew update && brew install azure-cli. If it fails with permission errors, follow Steps 2–4 above, then check the install with az --version.

Why does brew install azure-cli fail with a permission error? In my case, my user didn’t own some Homebrew directories under /usr/local. Both the OpenSSL and Python steps failed for that reason.

Why did I need to unlink python@3.11? Python hit its own permission error at a different location. Unlinking the existing Homebrew Python, together with the ownership fix, let the install complete.

Does this fix work on Apple Silicon Macs? The idea is the same, but Homebrew lives in /opt/homebrew on Apple Silicon. Adjust the paths to match the directories your error message names.

How do I know the install worked? Run az --version. If it prints version details, the CLI is installed. Then run az login to sign in.


Thanks for reading! You’re welcome to check out my other AI posts, or contact me via the links in the footer.

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.

Keep reading

All posts