Download packages with their dependencies, from various sources.

new_pkg_download_proposal(refs, ...)

Arguments

refs

Package names or references. See 'Package references' for the syntax.

...

Additional arguments, passed to pkg_download_proposal$new().

Value

new_pkg_download_proposal() returns a new pkg_download_proposal object.

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:

  1. Create a pkg_download_proposal object with new_pkg_download_proposal().

  2. Resolve all possible dependencies with pkg_download_proposal$resolve().

  3. Download all files with pkg_download_proposal$download().

  4. Get the data about the packages and downloads with pkg_download_proposal$get_downloads().

Methods

Public 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_refs()

The package refs that were used to create the pkg_download_proposal object.

Usage

pkg_download_proposal$get_refs()

Returns

A character vector of package refs that were used to create the pkg_download_proposal object.


Method get_config()

Configuration options for the pkg_download_proposal object. See 'Configuration' for details.

Usage

pkg_download_proposal$get_config()

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.

Usage

pkg_download_proposal$resolve()

Returns

The pkg_download_proposal object itself, invisibly.


Method async_resolve()

The same as resolve(), but asynchronous. This method is for advanced use.

Usage

pkg_download_proposal$async_resolve()

Returns

A deferred value.


Method get_resolution()

Query the result of the dependency resolution. This method can be called after resolve() has completed.

Usage

pkg_download_proposal$get_resolution()

Returns

A pkg_resolution_result object, which is also a tibble. 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.

Usage

pkg_download_proposal$download()

Returns

The pkg_download_proposal object, invisibly.


Method async_download()

The same as download(), but asynchronous. This method is for advanced use.

Usage

pkg_download_proposal$async_download()

Returns

A deferred value.


Method get_downloads()

Returns the summary of the package downloads.

Usage

pkg_download_proposal$get_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.

Usage

pkg_download_proposal$stop_for_download_error()


Method format()

Format a pkg_download_proposal object, typically for printing.

Usage

pkg_download_proposal$format(...)

Arguments

...

not used currently.

Returns

Nothing. A character vector, each element should be a line in the printout.


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.

Usage

pkg_download_proposal$print(...)

Arguments

...

not used currently.

Returns

The pkg_download_proposal object itself, invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage

pkg_download_proposal$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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()
#> + config: #> - library: #> - cache_dir: /tmp/RtmpReCZ7Q/file2d4a1ea1527c #> - package_cache_dir: <default> #> - metadata_cache_dir: /tmp/RtmpReCZ7Q/file2d4a2727f2e0 #> - platforms: source #> - cran-mirror: https://cloud.r-project.org #> - dependencies: direct: Depends, Imports, LinkingTo, indirect: Depends, Imports, LinkingTo #> - r-versions: 4.1.0 #> - build-vignettes: FALSE #> - metadata-update-after: 24 hours
# Method resolve() pdl <- new_pkg_download_proposal("pak") pdl$resolve() pdl$get_resolution()
#> # A tibble: 84 x 29 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 R6 stan… FALSE FALSE OK R6 2.5.0 MIT + … FALSE #> 2 asser… stan… FALSE FALSE OK assert… 0.2.1 GPL-3 FALSE #> 3 base6… stan… FALSE FALSE OK base64… 0.1-3 GPL-2 … TRUE #> 4 callr stan… FALSE FALSE OK callr 3.7.0 MIT + … FALSE #> 5 cli stan… FALSE FALSE OK cli 2.5.0 MIT + … FALSE #> 6 cliapp stan… FALSE FALSE OK cliapp 0.1.1 MIT + … FALSE #> 7 crayon stan… FALSE FALSE OK crayon 1.4.1 MIT + … FALSE #> 8 curl stan… FALSE FALSE OK curl 4.3.2 MIT + … TRUE #> 9 desc stan… FALSE FALSE OK desc 1.3.0 MIT + … FALSE #> 10 digest stan… FALSE FALSE OK digest 0.6.27 GPL (>… TRUE #> # … with 74 more rows, and 20 more variables: 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>, cache_status <chr>
# Method get_resolution() pdl <- new_pkg_download_proposal("r-lib/pkgdepends") pdl$resolve() pdl$get_resolution()
#> # A tibble: 67 x 29 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 r-lib… gith… TRUE TRUE OK pkgdep… 0.1.2.… MIT + … TRUE #> 2 R6 stan… FALSE FALSE OK R6 2.5.0 MIT + … FALSE #> 3 asser… stan… FALSE FALSE OK assert… 0.2.1 GPL-3 FALSE #> 4 callr stan… FALSE FALSE OK callr 3.7.0 MIT + … FALSE #> 5 cli stan… FALSE FALSE OK cli 2.5.0 MIT + … FALSE #> 6 crayon stan… FALSE FALSE OK crayon 1.4.1 MIT + … FALSE #> 7 curl stan… FALSE FALSE OK curl 4.3.2 MIT + … TRUE #> 8 desc stan… FALSE FALSE OK desc 1.3.0 MIT + … FALSE #> 9 digest stan… FALSE FALSE OK digest 0.6.27 GPL (>… TRUE #> 10 ellip… stan… FALSE FALSE OK ellips… 0.3.2 MIT + … TRUE #> # … with 57 more rows, and 20 more variables: priority <chr>, md5sum <chr>, #> # sha256 <chr>, filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <glue>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, cache_status <chr>
# Method download() pdl <- new_pkg_download_proposal("r-lib/pkgdepends") pdl$resolve() pdl$download()
#> Getting 33 pkgs (7.75 MB) and 34 pkgs with unknown sizes
#> Warning: cannot rename file '/tmp/RtmpReCZ7Q/file2d4a3bba3525/src/contrib/desc_1.3.0.tar.gz.tmp.1' to '/tmp/RtmpReCZ7Q/file2d4a3bba3525/src/contrib/desc_1.3.0.tar.gz', reason 'No such file or directory'
#> Got pkgdepends 0.1.2.9000 (source) (353.03 kB)
#> Got callr 3.7.0 (source) (436.19 kB)
#> Warning: cannot rename file '/tmp/RtmpReCZ7Q/file2d4a3bba3525/src/contrib/pkgbuild_1.2.0.tar.gz.tmp.1' to '/tmp/RtmpReCZ7Q/file2d4a3bba3525/src/contrib/pkgbuild_1.2.0.tar.gz', reason 'No such file or directory'
#> Got assertthat 0.2.1 (source) (52.33 kB)
#> Got cli 2.5.0 (source) (519.95 kB)
#> Got curl 4.3.2 (source) (905.95 kB)
#> Got ellipsis 0.3.2 (source) (40.29 kB)
#> Got desc 1.3.0 (source) (818.11 kB)
#> Got filelock 1.0.2 (source) (32.35 kB)
#> Got crayon 1.4.1 (source) (137.21 kB)
#> Got R6 2.5.0 (source) (63.36 kB)
#> Got magrittr 2.0.1 (source) (232.46 kB)
#> Got tibble 3.1.2 (source) (812.23 kB)
#> Got desc 1.3.0 (source) (818.11 kB)
#> Got jsonlite 1.7.2 (source) (536.21 kB)
#> Got pkgcache 1.2.2 (source) (164.09 kB)
#> Got vctrs 0.3.8 (source) (1.62 MB)
#> Got digest 0.6.27 (source) (357.39 kB)
#> Got glue 1.4.2 (source) (144.55 kB)
#> Got lifecycle 1.0.0 (source) (93.56 kB)
#> Got cli 2.5.0 (source) (519.95 kB)
#> Got crayon 1.4.1 (source) (137.21 kB)
#> Got glue 1.4.2 (source) (144.55 kB)
#> Got callr 3.7.0 (source) (436.19 kB)
#> Got pillar 1.6.1 (source) (1.04 MB)
#> Got lpSolve 5.6.15 (source) (1.50 MB)
#> Got pkgconfig 2.0.3 (source) (6.08 kB)
#> Got assertthat 0.2.1 (source) (52.33 kB)
#> Got utf8 1.2.1 (source) (237.66 kB)
#> Got processx 3.5.2 (source) (141.42 kB)
#> Got rematch2 2.1.2 (source) (13.37 kB)
#> Got withr 2.4.2 (source) (206.16 kB)
#> Got curl 4.3.2 (source) (905.95 kB)
#> Got lifecycle 1.0.0 (source) (93.56 kB)
#> Got digest 0.6.27 (source) (357.39 kB)
#> Got filelock 1.0.2 (source) (32.35 kB)
#> Got rlang 0.4.11 (source) (1.40 MB)
#> Got ps 1.6.0 (source) (119.67 kB)
#> Got fansi 0.5.0 (source) (541.99 kB)
#> Got ellipsis 0.3.2 (source) (40.29 kB)
#> Got pkgbuild 1.2.0 (source) (170.80 kB)
#> Got rprojroot 2.0.2 (source) (59.97 kB)
#> Got pkgbuild 1.2.0 (source) (170.80 kB)
#> Got prettyunits 1.1.1 (source) (10.37 kB)
#> Got uuid 0.1-4 (source) (49.54 kB)
#> Got rappdirs 0.3.3 (source) (12.29 kB)
#> Got zip 2.2.0 (source) (114.39 kB)
#> Got pkgcache 1.2.2 (source) (164.09 kB)
#> Got processx 3.5.2 (source) (141.42 kB)
#> Got R6 2.5.0 (source) (63.36 kB)
#> Got pkgconfig 2.0.3 (source) (6.08 kB)
#> Got prettyunits 1.1.1 (source) (10.37 kB)
#> Got rematch2 2.1.2 (source) (13.37 kB)
#> Got rappdirs 0.3.3 (source) (12.29 kB)
#> Got rprojroot 2.0.2 (source) (59.97 kB)
#> Got ps 1.6.0 (source) (119.67 kB)
#> Got utf8 1.2.1 (source) (239.46 kB)
#> Got zip 2.2.0 (source) (114.39 kB)
#> Got uuid 0.1-4 (source) (49.54 kB)
#> Got withr 2.4.2 (source) (94.28 kB)
#> Got fansi 0.5.0 (source) (40.91 kB)
#> Got lpSolve 5.6.15 (source) (205.50 kB)
#> Got magrittr 2.0.1 (source) (265.58 kB)
#> Got jsonlite 1.7.2 (source) (421.72 kB)
#> Got tibble 3.1.2 (source) (686.14 kB)
#> Got vctrs 0.3.8 (source) (782.61 kB)
#> Got pillar 1.6.1 (source) (1.08 MB)
#> Got rlang 0.4.11 (source) (861.73 kB)
pdl$get_downloads()
#> # A tibble: 67 x 34 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 r-lib… gith… TRUE TRUE OK pkgdep… 0.1.2.… MIT + … TRUE #> 2 R6 stan… FALSE FALSE OK R6 2.5.0 MIT + … FALSE #> 3 asser… stan… FALSE FALSE OK assert… 0.2.1 GPL-3 FALSE #> 4 callr stan… FALSE FALSE OK callr 3.7.0 MIT + … FALSE #> 5 cli stan… FALSE FALSE OK cli 2.5.0 MIT + … FALSE #> 6 crayon stan… FALSE FALSE OK crayon 1.4.1 MIT + … FALSE #> 7 curl stan… FALSE FALSE OK curl 4.3.2 MIT + … TRUE #> 8 desc stan… FALSE FALSE OK desc 1.3.0 MIT + … FALSE #> 9 digest stan… FALSE FALSE OK digest 0.6.27 GPL (>… TRUE #> 10 ellip… stan… FALSE FALSE OK ellips… 0.3.2 MIT + … TRUE #> # … with 57 more rows, and 25 more variables: priority <chr>, md5sum <chr>, #> # sha256 <chr>, filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <glue>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, cache_status <chr>, fulltarget <chr>, #> # fulltarget_tree <chr>, download_status <chr>, download_error <list>, #> # file_size <dbl>
# Method get_downloads() pdl <- new_pkg_download_proposal("pkgload") pdl$resolve() pdl$download()
#> Getting 6 pkgs (756.98 kB) and 10 pkgs with unknown sizes, 4 (1.08 MB) cached
#> Cached copy of R6 2.5.0 (source) is the latest build
#> Cached copy of cli 2.5.0 (source) is the latest build
#> Cached copy of crayon 1.4.1 (source) is the latest build
#> Cached copy of desc 1.3.0 (source) is the latest build
#> Cached copy of glue 1.4.2 (source) is the latest build
#> Cached copy of rlang 0.4.11 (source) is the latest build
#> Cached copy of rprojroot 2.0.2 (source) is the latest build
#> Cached copy of withr 2.4.2 (source) is the latest build
#> Cached copy of cli 2.5.0 (source) is the latest build
#> Cached copy of crayon 1.4.1 (source) is the latest build
#> Cached copy of desc 1.3.0 (source) is the latest build
#> Cached copy of glue 1.4.2 (source) is the latest build
#> Got pkgload 1.2.1 (source) (60.65 kB)
#> Got rstudioapi 0.13 (source) (110.47 kB)
#> Got pkgload 1.2.1 (source) (150.40 kB)
#> Got rstudioapi 0.13 (source) (273.40 kB)
pdl$get_downloads()
#> # A tibble: 20 x 34 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 R6 stan… FALSE FALSE OK R6 2.5.0 MIT + … FALSE #> 2 cli stan… FALSE FALSE OK cli 2.5.0 MIT + … FALSE #> 3 crayon stan… FALSE FALSE OK crayon 1.4.1 MIT + … FALSE #> 4 desc stan… FALSE FALSE OK desc 1.3.0 MIT + … FALSE #> 5 glue stan… FALSE FALSE OK glue 1.4.2 MIT + … TRUE #> 6 pkglo… stan… TRUE TRUE OK pkgload 1.2.1 GPL-3 TRUE #> 7 rlang stan… FALSE FALSE OK rlang 0.4.11 MIT + … TRUE #> 8 rproj… stan… FALSE FALSE OK rprojr… 2.0.2 MIT + … FALSE #> 9 rstud… stan… FALSE FALSE OK rstudi… 0.13 MIT + … FALSE #> 10 withr stan… FALSE FALSE OK withr 2.4.2 MIT + … FALSE #> 11 cli stan… FALSE FALSE OK cli 2.5.0 MIT + … FALSE #> 12 crayon stan… FALSE FALSE OK crayon 1.4.1 MIT + … FALSE #> 13 desc stan… FALSE FALSE OK desc 1.3.0 MIT + … FALSE #> 14 glue stan… FALSE FALSE OK glue 1.4.2 MIT + … TRUE #> 15 pkglo… stan… TRUE TRUE OK pkgload 1.2.1 GPL-3 TRUE #> 16 R6 stan… FALSE FALSE OK R6 2.5.0 MIT + … FALSE #> 17 rlang stan… FALSE FALSE OK rlang 0.4.11 MIT + … TRUE #> 18 rproj… stan… FALSE FALSE OK rprojr… 2.0.2 MIT + … FALSE #> 19 rstud… stan… FALSE FALSE OK rstudi… 0.13 MIT + … FALSE #> 20 withr stan… FALSE FALSE OK withr 2.4.2 MIT + … FALSE #> # … with 25 more variables: 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>, cache_status <chr>, fulltarget <chr>, #> # fulltarget_tree <chr>, download_status <chr>, download_error <list>, #> # file_size <dbl>
# 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 (+33 dependencies) #> (use `$download()` to download packages) #> (use `$get_resolution()` to see resolution results)
pdl$download()
#> Getting 9 pkgs (2.58 MB) and 34 pkgs with unknown sizes, 24 (5.17 MB) cached
#> Cached copy of pkgdepends 0.1.2.9000 (source) is the latest build
#> Cached copy of R6 2.5.0 (source) is the latest build
#> Cached copy of assertthat 0.2.1 (source) is the latest build
#> Cached copy of callr 3.7.0 (source) is the latest build
#> Cached copy of cli 2.5.0 (source) is the latest build
#> Cached copy of crayon 1.4.1 (source) is the latest build
#> Cached copy of curl 4.3.2 (source) is the latest build
#> Cached copy of desc 1.3.0 (source) is the latest build
#> Cached copy of digest 0.6.27 (source) is the latest build
#> Cached copy of ellipsis 0.3.2 (source) is the latest build
#> Cached copy of fansi 0.5.0 (source) is the latest build
#> Cached copy of filelock 1.0.2 (source) is the latest build
#> Cached copy of glue 1.4.2 (source) is the latest build
#> Cached copy of jsonlite 1.7.2 (source) is the latest build
#> Cached copy of lifecycle 1.0.0 (source) is the latest build
#> Cached copy of lpSolve 5.6.15 (source) is the latest build
#> Cached copy of magrittr 2.0.1 (source) is the latest build
#> Cached copy of pillar 1.6.1 (source) is the latest build
#> Cached copy of pkgbuild 1.2.0 (source) is the latest build
#> Cached copy of pkgcache 1.2.2 (source) is the latest build
#> Cached copy of pkgconfig 2.0.3 (source) is the latest build
#> Cached copy of prettyunits 1.1.1 (source) is the latest build
#> Cached copy of processx 3.5.2 (source) is the latest build
#> Cached copy of ps 1.6.0 (source) is the latest build
#> Cached copy of rappdirs 0.3.3 (source) is the latest build
#> Cached copy of rematch2 2.1.2 (source) is the latest build
#> Cached copy of rlang 0.4.11 (source) is the latest build
#> Cached copy of rprojroot 2.0.2 (source) is the latest build
#> Cached copy of tibble 3.1.2 (source) is the latest build
#> Cached copy of utf8 1.2.1 (source) is the latest build
#> Cached copy of uuid 0.1-4 (source) is the latest build
#> Cached copy of vctrs 0.3.8 (source) is the latest build
#> Cached copy of withr 2.4.2 (source) is the latest build
#> Cached copy of zip 2.2.0 (source) is the latest build
#> Cached copy of cli 2.5.0 (source) is the latest build
#> Cached copy of crayon 1.4.1 (source) is the latest build
#> Cached copy of desc 1.3.0 (source) is the latest build
#> Cached copy of fansi 0.5.0 (source) is the latest build
#> Cached copy of glue 1.4.2 (source) is the latest build
#> Cached copy of lifecycle 1.0.0 (source) is the latest build
#> Cached copy of lpSolve 5.6.15 (source) is the latest build
#> Cached copy of pillar 1.6.1 (source) is the latest build
#> Cached copy of pkgbuild 1.2.0 (source) is the latest build
pdl
#> <pkg_download_proposal> #> + refs: #> - r-lib/pkgdepends #> + has resolution (+33 dependencies) #> + has downloads #> (use `$get_resolution()` to see resolution results) #> (use `$get_downloads()` to get download data)