12

I am trying to install Azure CLI 2.0 on my mac. I followed official documentation but facing this error.

bash: az: command not found

How can I fix this error on mac?

Jahanzaib Aslam
  • 2,731
  • 3
  • 21
  • 26

3 Answers3

10

rather than following this link https://learn.microsoft.com/en-us/cli/azure/get-started-with-azure-cli I suggest to install using home-brew on mac. Its simpler

brew update && brew install azure-cli

ref: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-macos

Akash Verma
  • 638
  • 1
  • 11
  • 15
2

I hit the same issue.

Search around for how to create a ".bash_profile" file. This file usually (always?) exists at /Users/myusername/ folder

Then you will either create this file or edit this file.

Here is a "before" and "after" of my ".bash_profile".

export PATH=$PATH:/Applications/Terraform
export M2_HOME=/Users/shollid3/apache-maven-3.6.0
export PATH=$PATH:$M2_HOME/bin

and after

export PATH=$PATH:/Applications/Terraform
export PATH=$PATH:/usr/local/homebrew/bin
export M2_HOME=/Users/shollid3/apache-maven-3.6.0
export PATH=$PATH:$M2_HOME/bin

Obviously, the addition is

/usr/local/homebrew/bin

Use "where is" to (drum roll) find out where your "az" exists on your computer.

My "paper trail" was:

this below url

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-macos?view=azure-cli-latest

led me to this below url:

https://docs.brew.sh/Installation.html

and eventually, that is how I got "az" installed to /usr/local/homebrew/bin

But regardless of where you have your "az", you can see how to add/edit bash_profile to get the path pointed to where you "az" is.

granadaCoder
  • 26,328
  • 10
  • 113
  • 146
1

Try the following command, or simply close and restart the Terminal session:

exec -l $SHELL

If that does not fix the issue, please share the output of your PATH variable by running

echo $PATH

Matt Park
  • 15
  • 3
  • 1
    @Matt_Park Having the same problem. My `.bash_profile` contains `source '/Users/Gabe/lib/azure-cli/az.completion'` and here's my PATH `/Users/Gabe/.rvm/gems/ruby-2.4.0/bin:/Users/Gabe/.rvm/gems/ruby-2.4.0@global/bin:/Users/Gabe/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.composer/vendor/bin:/Users/Gabe/.rvm/gems/ruby-2.4.0/bin:/Users/Gabe/.rvm/gems/ruby-2.4.0@global/bin:/Users/Gabe/.rvm/rubies/ruby-2.4.0/bin:/Users/Gabe/.rvm/bin` – Gabe Rogan May 06 '17 at 14:57
  • 1
    Edit: `azure` is a command but `az` is not. So is `az` supposed to be an alias for `azure`?? – Gabe Rogan May 06 '17 at 16:08