71

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 SDK version is: 146.0.0
The latest available version is: 146.0.0

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                  Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│     Status    │                         Name                         │            ID            │    Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  47.9 MiB │
│ Not Installed │ Bigtable Command Line Tool                           │ cbt                      │   3.8 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool                      │ datalab                  │   < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator                             │ cloud-datastore-emulator │  15.4 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy)                    │ gcd-emulator             │  38.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator                               │ pubsub-emulator          │  21.0 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │   3.3 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java          │ 128.3 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │   7.2 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │  11.5 MiB │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │   < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries                             │ core                     │   5.7 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │   2.8 MiB │
│ Installed     │ Default set of gcloud commands                       │ gcloud                   │           │
│ Installed     │ gcloud Alpha Commands                                │ alpha                    │   < 1 MiB │
│ Installed     │ gcloud Beta Commands                                 │ beta                     │   < 1 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘

Then attempting to install kubectl

$ gcloud components install kubectl

You cannot perform this action because this Cloud SDK installation is 
managed by an external package manager.  If you would like to get the 
latest version, please see our main download page at:
https://cloud.google.com/sdk/
ERROR: (gcloud.components.install) The component manager is disabled for this installation

Any idea why is this error raised?

ScottMcC
  • 4,094
  • 1
  • 27
  • 35
Ivan Fernandez
  • 4,173
  • 5
  • 25
  • 30
  • 2
    Got it!. You need to install gcloud command line directly with a versioned archive instead of a package manager (apt-get or yum). It seems there is no other way to install certain aditional package if you use the later. – Ivan Fernandez Mar 09 '17 at 13:48
  • 1
    You can also install the components (or some of them anyway) using yum, look here: https://cloud.google.com/sdk/downloads#yum – Robert Lacok Mar 09 '17 at 14:08
  • I did that originally, still didn't work. Why are all MY problems ALWAYS unique in the universe? – Nathan McKaskle Aug 23 '23 at 20:21

7 Answers7

77

To add some more context to this answer for the Ubuntu OS, these are the steps that I took when I had already installed google-cloud-sdk using the apt-get package manager

  1. Remove the existing installation using

    sudo apt-get remove google-cloud-sdk

  2. Navigate to https://cloud.google.com/sdk/docs/quickstart-linux and follow the steps to download the correct tar.gz package for your system

  3. Navigate to the download directory and unzip the archive using

    tar -zxf google-cloud-sdk-*

  4. Install the SDK using

    ./google-cloud-sdk/install.sh

  5. Make the gcloud command available by either:

    • Running source ~/.bashrc or
    • Closing your current terminal session and opening a new one

Using this installation I was then able to update and install kubectl with the following commands

gcloud components update
gcloud components install kubectl
ScottMcC
  • 4,094
  • 1
  • 27
  • 35
  • 3
    After step 4, you'll need to restart your terminal for the changes to take effect. Otherwise, this solution solved all my problems installing Kubernetes on Ubuntu. – RDRR May 17 '19 at 13:36
  • I needed to use `sudo gcloud components install kubectl` – Yaakov Bressler Nov 05 '20 at 20:56
  • When I run 4.th command (install.sh) I am getting this kind of error: File "/usr/local/lib/python3.5/ssl.py", line 98, in import _ssl # if we can't import it, let the error propagate ImportError: No module named '_ssl' – Suat Atan PhD Dec 04 '20 at 07:41
  • Wrong answer, this is EXACTLY what I did and it still gives the same damn error claiming I installed it with a 3rd party packager which I ever so clearly did not. – Nathan McKaskle Aug 23 '23 at 20:20
44

The Cloud SDK component manager only works if you don't install the SDK through another package manager. If you want to use the component manager, you can install using one of these methods:

https://cloud.google.com/sdk/downloads#versioned

https://cloud.google.com/sdk/downloads#interactive

Additional packages are available in our deb and yum repos so all the same components are available, you just need to use your existing package manager to install them:

https://cloud.google.com/sdk/downloads#apt-get

https://cloud.google.com/sdk/downloads#yum

Mark
  • 2,265
  • 15
  • 13
  • 3
    Installed the SDK fine via apt, but tried `sudo apt-get install google-cloud-sdk-pubsub-emulator` and got the error: `E: Unable to locate package google-cloud-sdk-pubsub-emulator` – basickarl Aug 28 '17 at 19:13
  • You say "The Cloud SDK component manager only works if you don't install the SDK through another package manager." But in my case, I never installed gcloud; it comes preinstalled on every GCP instance. So, for those of us using docker, is that preinstallation useless? – carbocation Aug 16 '18 at 23:10
  • Different GCP images are managed by different people and so the preinstalled version of the Cloud SDK can vary. The debian images install the SDK using the apt-get method mentioned above and will have all those components available. Other distros manage their own SDK package and may not have all components available. If you need something that is not available, the best option is to uninstall the SDK that comes on the image, and install using one of the above methods. – Mark Aug 20 '18 at 14:41
  • Also installed via apt-get as per the instructions, also cannot install google-cloud-sdk-pubsub-emulator (or datastore) as per Karl's notes above. – El Yobo Feb 06 '19 at 01:56
  • 1
    If you get `E: Unable to locate package google-cloud-sdk-pubsub-emulator`, you need to add the Cloud SDK distribution URI as a package source, as explained [here](https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu). – xEc Dec 06 '19 at 11:35
  • In case anyone is here looking at this solution to install the docker credential helper component, it's 'not yet available' in apt repo's – Rondo Apr 01 '22 at 20:45
6

In case apt or apt-get does not uninstall gcloud try with snap remove google-cloud-sdk.

This might be the case if you use a newer Ubuntu version (eg. LTS 18.04).

Wal
  • 301
  • 2
  • 6
5

My Problem

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/

My Solution

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:

  1. 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
  1. 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.

Useful Troubleshooting Commands

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
superEb
  • 5,613
  • 35
  • 38
1
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/

I was unable to install the required kubectl gcloud component the reasion behind that was I used snap manager to install GCloud SDK so I also need to install kubectl via snap.

sudo snap install kubectl --classic

it works in my case.

Usman Ali Maan
  • 368
  • 2
  • 12
1

Answer from google support.

This can occur when Google Cloud SDK is installed via package manager like apt-get or yum.
If you would like to enable Google Cloud CLI compoenent manager, you can reinstall Cloud SDK using installer[1] after uninstall existing package-manager-installed Cloud SDK by following this document[2].
However installing 'docker-credential-gcr' is not supported by Cloud SDK so please consider to use gcloud credential helper[3] or install it via curl command[4].

[1] https://cloud.google.com/sdk/docs/install#installation_instructions

[2] https://cloud.google.com/sdk/docs/uninstall-cloud-sdk

mon
  • 18,789
  • 22
  • 112
  • 205
0

I had same issue on my side.

instead of installing it through apt tried it with snap https://cloud.google.com/sdk/docs/downloads-interactive

Following the same steps.

PS: dont forget to restart exec -l $SHELL

renish p.r
  • 105
  • 1
  • 5