Download packages with their dependencies, from various sources.
Arguments
- refs
Package names or references. See 'Package references' for the syntax.
- ...
Additional arguments, passed to
pkg_download_proposal$new()
.
Details
new_pkg_download_proposal()
creates a new object from the
pkg_download_proposal
class, that can be used to look up and download
R packages and their dependencies. The advantage of
new_pkg_download_proposal()
compared to using the
pkg_download_proposal constructor directly is that it avoids making
pkgdepends a build time dependency.
Typical workflow to download a set of packages:
Create a
pkg_download_proposal
object withnew_pkg_download_proposal()
.Resolve all possible dependencies with
pkg_download_proposal$resolve()
.Download all files with
pkg_download_proposal$download()
.Get the data about the packages and downloads with
pkg_download_proposal$get_downloads()
.
Methods
Method new()
Create a new pkg_download_proposal
object. Consider using
new_pkg_download_proposal()
instead of calling the constructor
directly.
The returned object can be used to look up (recursive) dependencies of R packages from various sources, and then to download the package files.
Usage
pkg_download_proposal$new(refs, config = list(), remote_types = NULL)
Arguments
refs
Package names or references. See 'Package references' for the syntax.
config
Configuration options, a named list. See 'Configuration'.
remote_types
Custom remote ref types, this is for advanced use, and experimental currently.
Examples
pdl <- pkg_download_proposal$new("r-lib/pkgdepends") pdl
Method get_config()
Configuration options for the pkg_download_proposal
object. See
'Configuration' for details.
Returns
Named list. See 'Configuration' for the configuration options.
Method resolve()
Resolve the dependencies of the specified package references. This usually means downloading metadata from CRAN and Bioconductor, unless already cached, and also from GitHub if GitHub refs were included, either directly or indirectly. See 'Dependency resolution' for details.
Method async_resolve()
The same as resolve()
, but asynchronous.
This method is for advanced use.
Method get_resolution()
Query the result of the dependency resolution. This method can be
called after resolve()
has completed.
Returns
A pkg_resolution_result object, which is also a data frame. See 'Dependency resolution' for its columns.
Method download()
Download all resolved packages. It uses the package cache in the pkgcache package by default, to avoid downloads if possible.
Method async_download()
The same as download()
, but asynchronous.
This method is for advanced use.
Method get_downloads()
Returns the summary of the package downloads.
Returns
A pkg_download_result object, which is a list. See pkg_download_result for details.
Method stop_for_download_error()
Throw and error if the some of the downloads have failed for the
most recent
pkg_download_proposal$download()
call.
Method format()
Format a pkg_download_proposal
object, typically for printing.
Method print()
Prints a pkg_download_proposal
object to the screen. The printout
includes:
The package refs.
Whether the object has the resolved dependencies.
Whether the resolution had errors.
Whether the downloads were completed.
Whether the downloads had errors.
Advice on which methods to call next.
See the example below.
Examples
# Method get_refs()
pdl <- new_pkg_download_proposal(c("pak", "jsonlite"))
pdl$get_refs()
#> [1] "pak" "jsonlite"
# Method get_config()
pdl <- new_pkg_download_proposal("pak")
pdl$get_config()
#> # pkg config
#> ## build_vignettes
#> <default>
#> [1] FALSE
#>
#> ## sysreqs_verbose
#> <default>
#> [1] TRUE
#>
#> ## sysreqs_db_update
#> <default>
#> [1] TRUE
#>
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/Rtmpkdyqa0/file19841d29e48e"
#>
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-22.04" "source"
#>
#> ## goal
#> <default>
#> [1] "unknown"
#>
#> ## r_versions
#> <default>
#> [1] "4.4.2"
#>
#> ## cache_dir
#> <default>
#> [1] "/tmp/Rtmpkdyqa0/file19844a7eda7d"
#>
#> ## library
#> <default>
#> NULL
#>
#> ## metadata_update_after
#> <default>
#> Time difference of 24 hours
#>
#> ## include_linkingto
#> <default>
#> [1] FALSE
#>
#> ## sysreqs_rspm_repo_id
#> <default>
#> [1] "1"
#>
#> ## sysreqs_update
#> <default>
#> [1] TRUE
#>
#> ## package_cache_dir
#> <default>
#> NULL
#>
#> ## sysreqs_rspm_url
#> <default>
#> [1] "https://packagemanager.posit.co"
#>
#> ## sysreqs_sudo
#> <default>
#> [1] TRUE
#>
#> ## sysreqs_db_update_timeout
#> <default>
#> Time difference of 5 secs
#>
#> ## sysreqs_lookup_system
#> <default>
#> [1] TRUE
#>
#> ## git_submodules
#> <default>
#> [1] FALSE
#>
#> ## sysreqs_platform
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-22.04"
#>
#> ## dependencies
#> <default>
#> [1] "Depends" "Imports" "LinkingTo"
#>
#> ## sysreqs
#> <default>
#> [1] TRUE
#>
#> ## sysreqs_dry_run
#> <default>
#> [1] FALSE
#>
#> ## windows_archs
#> <default>
#> [1] "prefer-x64"
#>
#> ## use_bioconductor
#> <default>
#> [1] TRUE
#>
#> ## cran_mirror
#> <default>
#> CRAN
#> "https://cran.rstudio.com"
#>
# Method resolve()
pdl <- new_pkg_download_proposal("pak")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 2 × 35
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 pak standard TRUE TRUE OK pak 0.8.0 GPL-3
#> 2 pak standard TRUE TRUE OK pak 0.8.0 GPL-3
#> # ℹ 27 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>,
#> # cache_status <chr>, sysreqs_packages <list>, …
# Method get_resolution()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 28 × 35
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 r-lib/pkgdepends github TRUE TRUE OK pkgdep… 0.8.0.… MIT + …
#> 2 callr stand… FALSE FALSE OK callr 3.7.6 MIT + …
#> 3 cli stand… FALSE FALSE OK cli 3.6.3 MIT + …
#> 4 curl stand… FALSE FALSE OK curl 6.0.0 MIT + …
#> 5 desc stand… FALSE FALSE OK desc 1.4.3 MIT + …
#> 6 filelock stand… FALSE FALSE OK filelo… 1.0.3 MIT + …
#> 7 jsonlite stand… FALSE FALSE OK jsonli… 1.8.9 MIT + …
#> 8 lpSolve stand… FALSE FALSE OK lpSolve 5.6.21 LGPL-2
#> 9 pkgbuild stand… FALSE FALSE OK pkgbui… 1.4.5 MIT + …
#> 10 pkgcache stand… FALSE FALSE OK pkgcac… 2.2.3 MIT + …
#> # ℹ 18 more rows
#> # ℹ 27 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, …
# Method download()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$download()
#> ℹ Getting 13 pkgs (4.04 MB) and 15 pkgs with unknown sizes
#> ✔ Cached copy of cli 3.6.3.9000 (source) is the latest build
#> ✔ Got filelock 1.0.3 (source) (15.44 kB)
#> ✔ Got pkgbuild 1.4.5 (source) (48.10 kB)
#> ✔ Got callr 3.7.6 (source) (104.36 kB)
#> ✔ Got filelock 1.0.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (24.75 kB)
#> ✔ Got ps 1.8.1 (source) (164.39 kB)
#> ✔ Got R6 2.5.1 (source) (63.42 kB)
#> ✔ Got desc 1.4.3 (source) (80.07 kB)
#> ✔ Got pkgcache 2.2.3 (source) (266.66 kB)
#> ✔ Got desc 1.4.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (334.41 kB)
#> ✔ Got zip 2.3.1 (source) (111.28 kB)
#> ✔ Got cli 3.6.3 (source) (568.16 kB)
#> ✔ Got R6 2.5.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (83.25 kB)
#> ✔ Got processx 3.8.4 (source) (163.98 kB)
#> ✔ Got callr 3.7.6 (x86_64-pc-linux-gnu-ubuntu-22.04) (445.43 kB)
#> ✔ Got curl 6.0.0 (source) (932.63 kB)
#> ✔ Got lpSolve 5.6.21 (source) (467.62 kB)
#> ✔ Got curl 6.0.0 (x86_64-pc-linux-gnu-ubuntu-22.04) (783.62 kB)
#> ✔ Got pkgbuild 1.4.5 (x86_64-pc-linux-gnu-ubuntu-22.04) (203.40 kB)
#> ✔ Got jsonlite 1.8.9 (source) (1.06 MB)
#> ✔ Got jsonlite 1.8.9 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.09 MB)
#> ✔ Got lpSolve 5.6.21 (x86_64-pc-linux-gnu-ubuntu-22.04) (374.10 kB)
#> ✔ Got processx 3.8.4 (x86_64-pc-linux-gnu-ubuntu-22.04) (444.53 kB)
#> ✔ Got cli 3.6.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.30 MB)
#> ✔ Got zip 2.3.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (636.87 kB)
#> ✔ Got ps 1.8.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (486.48 kB)
#> ✔ Got pkgcache 2.2.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (921.54 kB)
#> ✔ Got pkgdepends 0.8.0.9000 (source) (1.51 MB)
pdl$get_downloads()
#> # A data frame: 28 × 40
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 r-lib/pkgdepends github TRUE TRUE OK pkgdep… 0.8.0.… MIT + …
#> 2 callr stand… FALSE FALSE OK callr 3.7.6 MIT + …
#> 3 cli stand… FALSE FALSE OK cli 3.6.3 MIT + …
#> 4 curl stand… FALSE FALSE OK curl 6.0.0 MIT + …
#> 5 desc stand… FALSE FALSE OK desc 1.4.3 MIT + …
#> 6 filelock stand… FALSE FALSE OK filelo… 1.0.3 MIT + …
#> 7 jsonlite stand… FALSE FALSE OK jsonli… 1.8.9 MIT + …
#> 8 lpSolve stand… FALSE FALSE OK lpSolve 5.6.21 LGPL-2
#> 9 pkgbuild stand… FALSE FALSE OK pkgbui… 1.4.5 MIT + …
#> 10 pkgcache stand… FALSE FALSE OK pkgcac… 2.2.3 MIT + …
#> # ℹ 18 more rows
#> # ℹ 32 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, …
# Method get_downloads()
pdl <- new_pkg_download_proposal("pkgload")
pdl$resolve()
pdl$download()
#> ℹ Getting 7 pkgs (2.45 MB) and 14 pkgs with unknown sizes, 7 (1.19 MB) cached
#> ✔ Got lifecycle 1.0.4 (source) (107.66 kB)
#> ✔ Got glue 1.8.0 (source) (126.68 kB)
#> ✔ Got pkgload 1.4.0 (source) (85.66 kB)
#> ✔ Got rprojroot 2.0.4 (source) (59.95 kB)
#> ✔ Got withr 3.0.2 (source) (103.24 kB)
#> ✔ Cached copy of callr 3.7.6 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of cli 3.6.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of desc 1.4.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of pkgbuild 1.4.5 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of processx 3.8.4 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of ps 1.8.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of R6 2.5.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Got lifecycle 1.0.4 (x86_64-pc-linux-gnu-ubuntu-22.04) (125.14 kB)
#> ✔ Got rprojroot 2.0.4 (x86_64-pc-linux-gnu-ubuntu-22.04) (107.18 kB)
#> ✔ Got glue 1.8.0 (x86_64-pc-linux-gnu-ubuntu-22.04) (168.32 kB)
#> ✔ Got pkgload 1.4.0 (x86_64-pc-linux-gnu-ubuntu-22.04) (217.65 kB)
#> ✔ Got fs 1.6.5 (x86_64-pc-linux-gnu-ubuntu-22.04) (310.00 kB)
#> ✔ Got withr 3.0.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (223.69 kB)
#> ✔ Got rlang 1.1.4 (source) (767.04 kB)
#> ✔ Got fs 1.6.5 (source) (1.20 MB)
#> ✔ Got rlang 1.1.4 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.60 MB)
pdl$get_downloads()
#> # A data frame: 28 × 40
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 callr standard FALSE FALSE OK callr 3.7.6 MIT + fil…
#> 2 cli standard FALSE FALSE OK cli 3.6.3 MIT + fil…
#> 3 desc standard FALSE FALSE OK desc 1.4.3 MIT + fil…
#> 4 fs standard FALSE FALSE OK fs 1.6.5 MIT + fil…
#> 5 glue standard FALSE FALSE OK glue 1.8.0 MIT + fil…
#> 6 lifecycle standard FALSE FALSE OK lifecycle 1.0.4 MIT + fil…
#> 7 pkgbuild standard FALSE FALSE OK pkgbuild 1.4.5 MIT + fil…
#> 8 pkgload standard TRUE TRUE OK pkgload 1.4.0 GPL-3
#> 9 processx standard FALSE FALSE OK processx 3.8.4 MIT + fil…
#> 10 ps standard FALSE FALSE OK ps 1.8.1 MIT + fil…
#> # ℹ 18 more rows
#> # ℹ 32 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, …
# Method print()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> (use `$resolve()` to resolve dependencies)
pdl$resolve()
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> + has resolution (+13 dependencies)
#> (use `$download()` to download packages)
#> (use `$get_resolution()` to see resolution results)
pdl$download()
#> ℹ Getting 15 pkgs with unknown sizes, 13 (4.04 MB) cached
#> ✔ Cached copy of pkgdepends 0.8.0.9000 (source) is the latest build
#> ✔ Cached copy of cli 3.6.3.9000 (source) is the latest build
#> ✔ Cached copy of curl 6.0.0 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of desc 1.4.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of cli 3.6.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of filelock 1.0.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of jsonlite 1.8.9 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of lpSolve 5.6.21 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of pkgbuild 1.4.5 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of pkgcache 2.2.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of processx 3.8.4 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of ps 1.8.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of zip 2.3.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of callr 3.7.6 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#> ✔ Cached copy of R6 2.5.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> + has resolution (+13 dependencies)
#> + has downloads
#> (use `$get_resolution()` to see resolution results)
#> (use `$get_downloads()` to get download data)