azure-cli: unable to update cli using homebrew

I tried to install the latest CLI from the docs: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos?view=azure-cli-latest. I’m pretty sure I installed using brew so I ran:

brew update && brew install azure-cli

it ran for a while, then this:

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

Tried to do this manually:

~/src/vscode-docker$ brew link --overwrite python3
Linking /usr/local/Cellar/python3/3.6.4_2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

So I tried running with sudo and get a big error:

~/src/vscode-docker$ sudo brew link --overwrite python3
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

If i run brew upgrade azure-cli i see:

Error: azure-cli 2.0.26 already installed

if i which az gives me /usr/local/bin/az

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

I ran brew reinstall python3 to fix this

I solve my case, hope solve yours:

1.- Uninstall Azure CLI (could have an error, it is ok) brew uninstall azure-cli

2.- Update just brew brew update

3.- Upgrade brew brew upgrade

4.- Clean up brew brew cleanup

5.- Reinstall just the Azure CLI brew install azure-cli

6.- Check the CLI az help

Hope it works for you!

brew reinstall python3 fixed it for me, too.

It looks like I had originally installed the az CLI using the install script (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest). I cleaned that up using the instructions provided with that page, then installed using homebrew and it works. Generally. When I run az --version I get this:

~/src$ az --version
No module named 'pkg_resources'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/knack/cli.py", line 187, in invoke
    self.show_version()
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 79, in show_version
    print(get_az_version_string())
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 60, in get_az_version_string
    installed_dists = get_installed_cli_distributions()
  File "/usr/local/Cellar/azure-cli/2.0.28/libexec/lib/python3.6/site-packages/azure/cli/core/util.py", line 51, in get_installed_cli_distributions
    from pkg_resources import working_set
ModuleNotFoundError: No module named 'pkg_resources'

So, the same error for --version, but everything else seems to work.

You could also trybrew doctor and see if that provides any hints.