shellgoogle-cloud-platformgsutil

How can a billing project be stated in Google's command line tool `gsutil cp` on Linux?


I have to use Google's gsutil to download data from a project with "Requester pays" enabled. This does not seem to be possible.

Two different options are suggested on the internet for this case:

  1. gsutil -u <billing project> cp gs://<source project>/<directory>/<file> /<local download path>

See here and here. This fails with: CommandException: Invalid command "–u".

  1. gsutil --billing-project=<billing project> cp gs://<source project>/<directory>/<file> /<local download path>

See here. Similar to the one above, this fails with CommandException: Invalid command "--billing-project=<billing project>".

The 'command' in the statements above is cp. So apparently this has to come first and no options before that are recognized. But putting the -u option last gives another error:

$ gsutil --billing-project=<billing project> cp gs://<source project>/<directory>/<file> /<local download path>
BadRequestException: 400 Bucket is a requester pays bucket but no user project provided.

gsutil does not seem to have a man page. The help does seem to imply the existence of an option -u:

$ gsutil --help
Usage: gsutil [-D] [-DD] [-h header]... [-i service_account] [-m] [-o section:flag=value]... [-q] [-u user_project] [command [opts...] args...]
Available commands:
  ...
  cp               Copy files and objects
  ...

but gsutil cp clearly does not accept this option.

From it being recommended on the internet in the links above, I take it that either this option existed in the past, but google has elected to remove (but I also can't find it in the history here) it or there are different tools named gsutil around (possibly one not by Google but for the same purpose or possibly for different operating systems or possibly written in different languages?

The software I am working with is Arch Linux kernel 6.7.4 and Google cloud cli 464.0.0-1


Solution

  • I do not know the answer or why for the CLI gsutil

    Use the Google Cloud CLI gcloud storage cp command which does accept the --billing-project flag.

    Google Cloud CLI global command option --billing-project

    The documentation for the specifies that the --billing-project flag is supported at the bottom of this page:

    gcloud storage cp