Removing an Old Azure CLI that Wasn’t Installed Using Homebrew

Alastair Christian
Alastair Christian
Published in
3 min readMar 3, 2020

I’ve successfully moved my entire development environment on to my Mac (after many years of impatience waiting for the last of my .NET Framework projects to die or be ported to .NET Core). I try to make as much use of CLIs where they make sense and have come to enjoy using some of the features of the old Visual Studio Team Services CLI (VSTS CLI).

As part of setting up my Mac development environment, I wanted to make sure I kept my local system as clean as possible, so I decided to run the Azure CLI, Powershell Core and Azure Powershell in Docker containers. Everything was fine until today. Here is what I ran into and how I resolved it.

Firstly, the VSTS CLI is deprecated and its functionality moved into an Azure-Devops extension to the Azure CLI. I want to be able to run these devops commands from inside my source folders (e.g. after doing a git push I often use the CLI to create a pull request and open DevOps in my browser to that pull request so I can fill in some more details). Since I haven’t quite found time to move all my development into containers I had to bite the bullet and install the Azure CLI and Azure Devops Extension on my Mac.

The instructions at [Install the Azure CLI for macOS | Microsoft Docs] were nice and straightforward: use Homebrew. A quick brew list suggested that I didn’t have the CLI installed already (as expected, since I’ve been using the CLI in a container). I followed the instructions to brew install azure-cli and Homebrew duly reported that the azure-cli 2.1.0 had been successfully installed. But when I went to add the azure-devops extension to the Azure CLI I hit an error.

Since the Azure-Devops Extension instructions referred to the minimum version of the Azure CLI that was required (2.0.69), I did a quick check of my installed version number. It reported v2.0.3. That was odd, I’d seen Homebrew report that it had installed v2.1.0. Anyway, I tried updating Homebrew and reinstalling the Azure CLI. Same result.

It was time to interrogate my path to see where this conflicting version of the Azure CLI might live. At first glance there was nothing in there to indicate where the old CLI was hiding. But I noticed that the VSTS CLI was on the path and sitting in the /Users/alastairchristian/lib/ directory. Well, since I’d want to be uninstalling that as well I removed it from the path and went to the directory to delete its files as well. Lo-and-behold there was an azure-cli directory in /Users/alastairchristian/lib/ as well.

I deleted the azure-cli directory and, since I couldn’t see any reference to it on the path, tested the effect by running az -v. This returned the error:

/Users/alastairchristian/bin/az: line 2: /Users/alastairchristian/lib/azure-cli/bin/python: No such file or directory
Photo by Daniel Mingook Kim on Unsplash

Ok, now we were getting somewhere. I knew that /Users/alastairchristian/bin was on the path and it seems that something I did (knowingly or not) had installed the Azure CLI in that manner. The final step was to remove the az directory and then reinstall the Azure CLI from Homebrew. Everything was now hunky dory.

Whether anyone else has ended up in this situation I don’t know, but hopefully it may save someone some time.

--

--