How to Fix -bash: gcloud command not found – While installing Google Cloud SDK

The -bash: gcloud command not foundĀ error is raised while installing the Google Cloud SDK, which means the gcloud command-line tool is not in your system’s PATH.

To fix this issue, follow these steps.

Step 1: Verify the Google Cloud SDK installation

Make sure you have installed the Google Cloud SDK correctly. If you haven’t installed it yet, follow the installation instructions for your operating system from the official documentation: https://cloud.google.com/sdk/docs/install.

Step 2: Locate the gcloud executable

Find the directory where the Google Cloud SDK is installed. By default, it’s installed in the following locations:

  1. Linux and macOS: $HOME/google-cloud-sdk
  2. Windows: %USERPROFILE%\google-cloud-sdk

In the installation directory, you should find the gcloud executable in the bin folder.

Step 3: Add the gcloud executable to your system’s PATH:

To make the gcloud command available, you need to add the path to the gcloud executable to your system’s PATH variable. Here’s how to do it for each operating system:

Linux and macOS

Open your terminal and add the following lines to your shell profile file (e.g., ~/.bashrc, ~/.bash_profile, or ~/.zshrc, depending on your shell):

Save the file and restart your terminal or run source <your-shell-profile-file> (e.g., source ~/.bashrc) to apply the changes immediately.

Windows

  1. Right-click on “Computer” or “This PC” and select “Properties.”
  2. Click on “Advanced system settings” on the left side.
  3. In the “System Properties” window, go to the “Advanced” tab and click on the “Environment Variables” button.
  4. In the “Environment Variables” window, find the “Path” variable under the “System variables” section, select it, and click on “Edit.”
  5. Click on “New” and add the path to the gcloud executable (e.g., %USERPROFILE%\google-cloud-sdk\bin).
  6. Click “OK” on all open windows to save the changes.

Step 4: Verify that the gcloud command is available

Open a new terminal or command prompt and run gcloud -v or gcloud version.

If the installation and configuration were successful, you should see the version information for the Google Cloud SDK.

After following these steps, the “gcloud command not found” error should be resolved, and you should be able to use the gcloud command-line tool.

Leave a Comment