Encountering the “bash: gcloud command not found” error on macOS is a common issue for users trying to use Google Cloud’s command-line interface. This error typically arises when the gcloud CLI isn’t properly installed or configured, making it a frequent hurdle for macOS users working with Google Cloud services.
The error “bash: gcloud command not found” on macOS indicates that the gcloud
command-line tool, part of the Google Cloud SDK, is either not installed or not properly configured in your system’s PATH.
gcloud
command to interact with Google Cloud services.gcloud
executable might not be in your system’s PATH. This means your terminal can’t locate the command.gcloud
command.export PATH=$PATH:/path/to/google-cloud-sdk/bin
to your shell profile (e.g., .bash_profile
, .zshrc
).gcloud init
to initialize the SDK and ensure it’s correctly configured.Check Installation Directory:
cd ~/google-cloud-sdk
.Verify Files:
ls
.install.sh
and bin/gcloud
are present.Check PATH:
echo $PATH
.google-cloud-sdk/bin
is included.Test gcloud Command:
gcloud --version
.Initialize gcloud:
gcloud init
.If any step fails, reinstall the SDK.
Here are the steps to update your PATH variable on macOS to resolve the ‘bash: gcloud: command not found’ error:
Open Terminal: You can find it in Applications > Utilities > Terminal.
Locate your shell configuration file:
~/.bash_profile
or ~/.bashrc
~/.zshrc
Open the file in a text editor:
nano ~/.bash_profile
or
nano ~/.zshrc
Add the Google Cloud SDK path:
export PATH=$PATH:/path/to/google-cloud-sdk/bin
Save and close the file:
nano
, press CTRL + X
, then Y
, and Enter
.Apply the changes:
source ~/.bash_profile
or
source ~/.zshrc
Verify the installation:
gcloud version
This should resolve the ‘gcloud command not found’ error on your macOS.
Install Google Cloud SDK:
curl https://sdk.cloud.google.com | bash
Update PATH:
.bash_profile
or .zshrc
file and add:source $HOME/google-cloud-sdk/path.bash.inc
source $HOME/google-cloud-sdk/completion.bash.inc
source ~/.bash_profile # or source ~/.zshrc
Verify Installation:
gcloud
is recognized:gcloud version
This should ensure your system recognizes the gcloud
command.
Sure, here are the steps to reinstall the Google Cloud SDK on a Mac:
Download the installation script:
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-<version>-darwin-x86_64.tar.gz
Extract the downloaded archive:
tar -xf google-cloud-cli-<version>-darwin-x86_64.tar.gz
Run the installation script:
./google-cloud-sdk/install.sh
Initialize the SDK:
gcloud init
Replace <version>
with the latest version number available. This should resolve the ‘bash: gcloud: command not found’ error on your Mac.
: Google Cloud SDK Installation
: Google Cloud CLI Documentation
Follow these steps:
<curl https://sdk.cloud.google.com | bash>
in your terminal.<source $HOME/google-cloud-sdk/path.bash.inc>
and <source $HOME/google-cloud-sdk/completion.bash.inc>
to your .bash_profile
or .zshrc
file.<source ~/.bash_profile>
or <source ~/.zshrc>
.<gcloud version>
.Alternatively, you can reinstall the Google Cloud SDK by downloading the installation script, extracting the archive, running the installation script, and initializing the SDK.
It is essential to properly install and configure the Google Cloud SDK to avoid this error. You can refer to the official documentation for more information on installing and configuring the Google Cloud CLI.