Author: AnVIL Team
Date: 2026-05-24

# GCPtools

AnVIL Team

#### May 24, 2026

#### Package

GCPtools 1.3.2

# 1 GCPtools

GCPtools is a package that provides an interface to Google Cloud Platform (GCP) tools, primarily the `gcloud` and `gsutil` utilities. It allows users to interact with GCP services such as Google Cloud Storage (GCS) and Google Compute Engine (GCE) directly from R.

# 2 Installation and Load

You can install the latest version of `GCPtools` from GitHub using the following:

    if (!require("BiocManager", quietly = TRUE))
        install.packages("BiocManager")
    BiocManager::install("Bioconductor/GCPtools")

After installation, you can load the package using:

    library(GCPtools)

# 3 `gcloud` Command Line Utility

## 3.1 Check for `gcloud` SDK

The `gcloud_exists()` function is used to check if the `gcloud` command line utility is available on your system.

    gcloud_exists()
    #> [1] FALSE

## 3.2 `gcloud` Help

The package provides a function to display the help for the `gcloud` command line utility. This can be useful to understand the available commands and options. They can be used in conjunction with `gcloud_cmd()` to run specific commands.

    gcloud_help() |>
        head(10L)

## 3.3 Access Token

The package provides functions to interact with GCP services. For example, you can use `gcloud_access_token()` to obtain an access token for a specific service. This is currently in use by `AnVIL` and `AnVILGCP` R packages.

    gcloud_access_token("terra")

## 3.4 Command Execution

You can execute `gcloud` commands using the `gcloud_cmd()` function. This function allows you to run any `gcloud` command directly from R, making it easy to interact with GCP services without leaving the R environment.

    gcloud_cmd("version")

## 3.5 List of available functions

The package provides a variety of functions to interact with GCP services.

- `gcloud_exists()`: tests whether the `gcloud()` command can be found.
- `gcloud_account()`: report the current gcloud account via ⁠gcloud config get-value account⁠.
- `gcloud_project()`: report the current gcloud project via `⁠gcloud config get-value project`⁠.
- `gcloud_help()`: queries gcloud for help for a command or sub-comand via `⁠gcloud help ...`.
- `gcloud_cmd()`: `gcloud` command execution via `⁠gcloud ...`. Use pre-defined functions in preference to this.
- `gcloud_storage()`: `⁠gcloud` storage⁠ command execution via `⁠gcloud storage ...`⁠. Typically used for bucket management commands such as `rm` and `cp`.
- `gcloud_storage_buckets()`: interface to the `⁠gcloud storage buckets`⁠ command. It can create a new bucket via `⁠gcloud storage buckets create ...⁠`.

# 4 `gsutil` Command Line Utility

## 4.1 Check for `gsutil` resources

The `gsutil_exists()` function checks if a bucket or object exists in Google Cloud Storage (GCS).

    gsutil_exists("gs://your-bucket-name")

## 4.2 `gsutil` Help

The `gsutil_help()` function displays the help for the `gsutil` command line utility. This can be useful to understand the available commands and options and how to use them effectively.

    gsutil_help()

The package also includes functions to manage Google Cloud Storage buckets and objects, such as `gsutil_ls()` to list objects in a bucket and `gsutil_cp()` to copy files to and from GCS.

## 4.3 List of available functions

The package provides a variety of functions to interact with GCS.

- `gsutil_requesterpays()`: does the Google bucket require that the requester pay for access?
- `gsutil_requesterpays_flag()`: return the `-u <gcloud_project>` flag if the bucket requires that the requester pay for access.
- `gsutil_exists()`: check if the bucket or object exists.
- `gsutil_stat()`: print, as a side effect, the status of a bucket, directory, or file.
- `gsutil_rsync()`: synchronize a source and a destination.
- `gsutil_cat()`: concatenate bucket objects to standard output
- `gsutil_help()`: print ‘man’ page for the `gsutil` command or subcommand.
- `gsutil_pipe()`: create a pipe to read from or write to a Google bucket object.

# 5 Disclaimer

This package is not an official Google product, nor is it affiliated with or endorsed by Google LLC. It is developed and maintained by the AnVIL team to provide a convenient interface to GCP tools for R users on the AnVIL platform.

Only the above set of `gcloud` and `gsutil` commands are supported.

# 6 SessionInfo

    sessionInfo()
    #> R version 4.6.0 RC (2026-04-17 r89917)
    #> Platform: x86_64-pc-linux-gnu
    #> Running under: Ubuntu 24.04.4 LTS
    #>
    #> Matrix products: default
    #> BLAS:   /home/biocbuild/bbs-3.24-bioc/R/lib/libRblas.so
    #> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
    #>
    #> locale:
    #>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    #>  [3] LC_TIME=en_GB              LC_COLLATE=C
    #>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    #>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    #>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    #> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    #>
    #> time zone: America/New_York
    #> tzcode source: system (glibc)
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] GCPtools_1.3.2   BiocStyle_2.41.0
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] vctrs_0.7.3          httr_1.4.8           cli_3.6.6
    #>  [4] knitr_1.51           rlang_1.2.0          xfun_0.57
    #>  [7] otel_0.2.0           purrr_1.2.2          generics_0.1.4
    #> [10] jsonlite_2.0.0       glue_1.8.1           htmltools_0.5.9
    #> [13] BiocBaseUtils_1.15.1 sass_0.4.10          rmarkdown_2.31
    #> [16] rappdirs_0.3.4       tibble_3.3.1         evaluate_1.0.5
    #> [19] jquerylib_0.1.4      fastmap_1.2.0        yaml_2.3.12
    #> [22] lifecycle_1.0.5      httr2_1.2.2          bookdown_0.46
    #> [25] BiocManager_1.30.27  compiler_4.6.0       dplyr_1.2.1
    #> [28] pkgconfig_2.0.3      tidyr_1.3.2          digest_0.6.39
    #> [31] R6_2.6.1             tidyselect_1.2.1     pillar_1.11.1
    #> [34] magrittr_2.0.5       bslib_0.11.0         tools_4.6.0
    #> [37] AnVILBase_1.7.0      cachem_1.1.0