GoogleCloudPlatform/gsutil

gsutil ignores XDG basedir spec

Opened this issue ยท 11 comments

Many *nix programs now adhere to the XDG Base Directory Specification. I'd love to see gsutil follow suit, or at least gain some built-in compatibility with it.

Here is the spec itself, and while I don't use Arch Linux, there's a good write-up on the wiki that explains the spec a bit more. It also has a list of programs that utilize the spec and workarounds for some of those that don't.

As it specifically relates to gsutil, it would be nice if the program checked for the configuration file in $XDG_CONFIG_HOME/gsutil/boto (defaulting back to ~/.boto), and for the state directory in $XDG_CACHE_HOME/gsutil (defaulting back to ~/.gsutil).

(I know you can set the BOTO_CONFIG environment variable to set the location of the config file, and inside said config file you can specify state_dir, but when you're running gsutil through gcloud it's not always obvious where to do that.)

I just found .gsutil in my home directory I don't know what applications use it though

This should be fixed.

Guys, please fix this.

This behavior is unacceptable in 2021, please stop filling our home directories with trash.

(I know you can set the BOTO_CONFIG environment variable to set the location of the config file, and inside said config file you can specify state_dir, but when you're running gsutil through gcloud it's not always obvious where to do that.)

Can you elaborate more on this? It could be useful in the meantime.

Exactly as it says. You'd set BOTO_CONFIG to something e.g. ~/.config/gsutil/config

and within there you'd put state_dir = $XDG_DATA_HOME/gsutil if it accepts vars or manually put state_dir = /home/blah/.local/share/gsutil (I've used XDG_DATA_HOME since it's more appropriate for state than XDG_CACHE_HOME

# 'state_dir' specifies the base location where files that
# need a static location are stored, such as pointers to credentials,
# resumable transfer tracker files, and the last software update check.
# By default these files are stored in ~/.gsutil
#state_dir = <file_path>

Not tried it though

Now that gcloud storage has been promoted to GA, another workaround is to just use gcloud storage everywhere instead of gsutil. gcloud roughly follows the XDG basedir spec, storing its configuration in ~/.config/gcloud by default (can be overridden by $CLOUDSDK_CONFIG).

Now that gcloud storage has been promoted to GA, another workaround is to just use gcloud storage everywhere instead of gsutil. gcloud roughly follows the XDG basedir spec, storing its configuration in ~/.config/gcloud by default (can be overridden by $CLOUDSDK_CONFIG).

I was excited to hear this!

Unfortunately, I can't find a gcloud storage equivalent to gsutil du, and https://cloud.google.com/storage/docs/getting-bucket-information still says to use gsutil du.

If anyone happens to know a way to use gcloud storage to list disk usage for a bucket, I'd be glad to hear it.

Unfortunately we haven't completed gcloud storage du yet, but we're planning on starting work on very soon!

Unfortunately we haven't completed gcloud storage du yet, but we're planning on starting work on very soon!

Glad to hear it! Is there a tracking issue I can follow?
(I'm eager to switch as soon as possible, if this issue won't be addressed in gsutil.)

Glad to hear it! Is there a tracking issue I can follow?

poke ๐Ÿ˜€

We have it scheduled for Q1, so with luck you should see it by the end of March.