I am trying to install several GCP components from the gcloud command-line tool and always get the same error:
$ gcloud components list
Your current Cloud S
I wanted to upgrade the gcloud CLI version on an existing GCE instance (Ubuntu Xenial), and running gcloud components update resulted in this:
# gcloud components update
ERROR: (gcloud.components.update) You cannot perform this action because this Cloud SDK installation is managed by an external package manager.
Please consider using a separate installation of the Cloud SDK created through the default mechanism described at: https://cloud.google.com/sdk/
What I found is that the SDK executables are installed in /usr/lib/google-cloud-sdk and are included on the PATH via symlinks in /usr/bin:
# ll /usr/bin | grep google-cloud
lrwxrwxrwx 1 root root 30 Aug 20 2018 bq -> ../lib/google-cloud-sdk/bin/bq*
lrwxrwxrwx 1 root root 34 Aug 20 2018 gcloud -> ../lib/google-cloud-sdk/bin/gcloud*
lrwxrwxrwx 1 root root 52 Aug 20 2018 git-credential-gcloud.sh -> ../lib/google-cloud-sdk/bin/git-credential-gcloud.sh*
lrwxrwxrwx 1 root root 34 Aug 20 2018 gsutil -> ../lib/google-cloud-sdk/bin/gsutil*
Therefore, to install the latest version, I followed steps 3 and 4 from https://cloud.google.com/sdk/docs/quickstart-linux:
- Download the archive file best suited to your operating system.
# curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-247.0.0-linux-x86_64.tar.gz
- Extract the archive to any location on your file system; preferably, your Home folder.
# tar zxvf google-cloud-sdk-247.0.0-linux-x86_64.tar.gz google-cloud-sdk
and then just replaced the old /usr/lib/google-cloud-sdk directory with the new one:
# mv /usr/lib/google-cloud-sdk /usr/lib/google-cloud-sdk-ORIG
# mv google-cloud-sdk /usr/lib/
This allows the symlinks already on the PATH to continue to work, keeps existing auth/config in place, and appears to support upgrades via gcloud components update in the future:
# gcloud components update
All components are up to date.
It might be helpful to run these before and after you upgrade gcloud.
Where is gcloud on your PATH:
$ which gcloud
/usr/bin/gcloud
What version of gcloud are you using:
$ gcloud version
Google Cloud SDK 247.0.0
bq 2.0.43
core 2019.05.17
gsutil 4.38
What credentials is gcloud using (by default):
$ gcloud auth list
What config is gcloud using (by default):
$ gcloud config list