Google-cloud-sdk and installing extra components?

I tried installing extra components to gcloud and got this error:

$ gcloud components install app-engine-python
ERROR: (gcloud.components.install) 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:

I expected something like this, and went to to see if there’s already a way to specify which extra components to install, but I couldn’t see any. I found this open issue without any comments: My question is this: Is there a way to install gcloud with extra components already? Or is there an alternative to use gcloud with extra components on NixOS?


Does anyone knows a way to do this?

I’m actually trying to figure this out myself as I’ve encountered a bug with the app-gradle-plugin for GCE and the suggested workaround was to install the app-engine-java component:

I ran into this as well.

As a workaround I use the following shell.nix:

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
  name = "google-cloud-sdk";

  targetPkgs = pkgs: [

and inside that shell use the ‘regular’ gcloud tool downloaded from Installing Cloud SDK  |  Cloud SDK Documentation  |  Google Cloud

I would also love a declarative way to do this though :wink:


It seems there is a way to accomplish this now, by this comment added yesterday:

FYI this was just added to nixpkgs. You can do the following:

google-cloud-sdk.withExtraComponents ([])

I tried applying it, but failed. I’m using home-manager on elementaryos, can someone help me understand how to apply this in this context? Thanks!


As of the time of your comment, that change hasn’t landed on nixpkgs-unstable yet. That is likely why it is failing for you. Consider including error messages next time.


I’m using home-manager and the following line works for me:

home.packages = with pkgs; [
  # ...
  (google-cloud-sdk.withExtraComponents [google-cloud-sdk.components.gke-gcloud-auth-plugin])
  # ...