简体   繁体   中英

Find out where Google Cloud SDK is installed

I need to add the Google Cloud SDK in the PATH . So I need the path to where is installed. Is there any gcloud... command which gives me this information?

If not I have to go through the symlink in which gcloud , etc.

Any cleaner solution for this problem?

The following command will give you the information you're looking for:

$ gcloud info --format="value(installation.sdk_root)"
/path/to/google-cloud-sdk/

You need to append /bin .

You also have lots of other paths available: config.paths.global_config_dir , installation.sdk_root , and so on. Look at the output of gcloud info --format=json for all available properties to query.

As of March 2022, the gcloud sdk link indicates you can have the SDK for client libraries Java, Python, Node.js, Ruby, .Net and Php.

In addition you can have the CLI too. If you have installed the CLI, part of the ( optional ) install process is to add the gcloud binary path to your PATH thus you can find it.

This script is called path.bash.inc, path.zsh.inc etc and depending on what your default shell is it will run the correct path.your_shell.inc file. If you have never run that, then it is possible your gcloud was installed in a directory that you lost track of.

If that is the case, then you have to simply run a "find" from the root

find / -name gcloud -type f -ls 2>/dev/zero

This contrasts with

  1. AWS cli, that gets installed into system common PATH directory like /usr/local/bin on Mac

2 AZ cli, that gets installed using homebrew on Mac - under /opt/homebrew/bin path - which, if you used a Mac, already is in your Path.

I used:

dirname $(which gcloud)

And worked like a charm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM