How to Resolve the "Command Not Found" Error After Installing gcloud CLI on Mac OS
A Step-by-Step Guide to Fixing the gcloud Installation Issue Using Homebrew, with Solutions for Common Terminal Errors
Here’s how to Fix the Error After Installing the gcloud CLI on Mac OS
While creating a recent post about setting up Google App Engine, I had to download and install the gcloud CLI, and I kept encountering this error even after attempting to fix it multiple times. There are many different strategies on how to resolve this issue, but here’s what worked for me on my Mac OS, including some potential gotchas:
Open the Mac OS “Terminal” application.
Install the google-cloud-sdk with Homebrew by running this command:
brew install --cask google-cloud-sdk
If you don’t have Homebrew, you can install it from here: https://brew.sh/
Now, try:
gcloud infoIt worked if you get info about gcloud, instead of “command not found”
If you’re still getting the “command not found”, try running the following commands
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"Now, try:
gcloud infoIt worked in you get info about gcloud, instead of “command not found”
⚠️ If you encounter an error like this:
-sh: autoload: command not found
-sh: zmodload: command not found
-sh: ((: $+functions[compdef] : syntax error: operand expected (error token is "$+functions[compdef] ")
-sh: autoload: command not foundTry swapping zsh with bash in the commands, so they both look like this...
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"On my machine, it was zsh for the first command and bash for the second. 😅
I hope this helps with this tricky/annoying issue!
Cheers 🍻,
- Bob


