How to install Google Cloud CLI on macOS?

Pre-requisites

Before the installation of the gcloud CLI, confirm that Python 3 is installed. Python 3.5 or higher, 3.7 is recommended.

Installation steps

Follow the following steps to install the Google Cloud CLI:

Step 1: Download source

Download one of the following tarball depending on your hardware name. If you don’t know what your hardware name is, run the uname -m command:

Step 2: Extract the content

Open the downloaded tar.gz file to extract the content of the tarball at any location (the home directory is recommended).

Note: To replace the existing installation, delete all content of the google-cloud-sdk directory and extract the content in the google-cloud-sdk directory.

Step 3: Install gcloud

From the root folder, run the following command to execute the installation script:

./google-cloud-sdk/install.sh

To install google-cloud-cli non-interactively, set all preferences as flags. Use the --help flag with the above command to see all preferences.

Note: Use the --screen-reader=true flag with the above command to turn on the screen reader mode while installation.

Step 4: Initialize gcloud

Use the following command to initialize the gcloud CLI:

./google-cloud-sdk/bin/gcloud init

Step 5: Install additional gcloud components (optional)

Use the following command to install the additional components of gcloud:

gcloud components install [COMPONENT_ID]

For example, use the following command to install the AppCtl component:

gcloud components install appctl

Similarly, update and remove keywords can be used instead of install to update and remove the gcloud components.

Free Resources