Oh really? Ok, let's use flox

Here is a little session

± gcloud auth login                                                                                                                                                                                                                                                                                                                                                  gcloud
ERROR: gcloud failed to load: module 'collections' has no attribute 'Mapping'
    gcloud_main = _import_gcloud_main()
    import googlecloudsdk.gcloud_main
    from googlecloudsdk.calliope import cli
    from googlecloudsdk.calliope import actions
    from googlecloudsdk.calliope import markdown
    from googlecloudsdk.calliope import usage_text
    from googlecloudsdk.calliope import parser_arguments
    from googlecloudsdk.calliope import parser_completer
    from googlecloudsdk.core.console import progress_tracker
    class _BaseStagedProgressTracker(collections.Mapping):

This usually indicates corruption in your gcloud installation or problems with your Python interpreter.

Please verify that the following is the path to a working Python 2.7 or 3.5+ executable:
    /usr/local/bin/python3

If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 or 3.5+ executable.

If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here:
    https://cloud.google.com/sdk/

Ok, what about:

± flox install -e gcloud google-cloud-sdk

Success!

± . <(flox activate -e gcloud)

flox [gcloud default]
± gcloud auth login                                                                                                                                                                                                                                                                                                                                                  Your browser has been opened to visit:
...

I’m not sure yet if gcloud needs an environment on its own but not having to worry about python dependencies is a great win :slight_smile:.

5 Likes

Love the post, thank you! :smiling_face_with_three_hearts:

@etorreborre Thank you!
Did you find out how to install extra components of gcloud, like gke-gcloud-auth-plugin ?

I found that in nixpkgs docs:

let
  gdk = pkgs.google-cloud-sdk.withExtraComponents( with pkgs.google-cloud-sdk.components; [
    gke-gcloud-auth-plugin
  ]);
in
{
  packages = [
    gdk
  ];
}

https://nixos.wiki/wiki/Google_Cloud_SDK

Does anyone know how can that be done with flox? How will it look in manifest.toml?
Thanks!

It’s not currently possible to specify withExtraComponents through the manifest.toml. However another user recently posted a solution using our Flake support. I’ve filed a feature request, which includes details of that workaround, here:

Please let us know if you have any problems getting it working.

1 Like