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_proposalobject 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
refsPackage names or references. See 'Package references' for the syntax.
configConfiguration options, a named list. See 'Configuration'.
remote_typesCustom 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] FALSE
#>
#> ## sysreqs_db_update
#> <default>
#> [1] TRUE
#>
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/RtmpPPF5AH/file25f0a9511545a0"
#>
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-24.04" "source"
#>
#> ## goal
#> <default>
#> [1] "unknown"
#>
#> ## r_versions
#> <default>
#> [1] "4.5.1"
#>
#> ## cache_dir
#> <default>
#> [1] "/tmp/RtmpPPF5AH/file25f0a93afb124c"
#>
#> ## 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] FALSE
#>
#> ## 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-24.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://cloud.r-project.org"
#>
# 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 needscompilation
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl>
#> 1 pak standa… TRUE TRUE OK pak 0.9.3 GPL-3 TRUE
#> 2 pak standa… TRUE TRUE OK pak 0.9.4 GPL-3 TRUE
#> # ℹ 26 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>, sysreqs <chr>, os_type <chr>,
#> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>,
#> # sysreqs_post_install <chr>, sysreqs_install <chr>
# Method get_resolution()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 27 × 35
#> 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.9.1.… MIT + … TRUE
#> 2 R6 stan… FALSE FALSE OK R6 2.6.1 MIT + … FALSE
#> 3 callr stan… FALSE FALSE OK callr 3.7.6 MIT + … FALSE
#> 4 cli stan… FALSE FALSE OK cli 3.6.6 MIT + … TRUE
#> 5 curl stan… FALSE FALSE OK curl 7.0.0 MIT + … TRUE
#> 6 desc stan… FALSE FALSE OK desc 1.4.3 MIT + … FALSE
#> 7 filel… stan… FALSE FALSE OK filelo… 1.0.3 MIT + … TRUE
#> 8 jsonl… stan… FALSE FALSE OK jsonli… 2.0.0 MIT + … TRUE
#> 9 lpSol… stan… FALSE FALSE OK lpSolve 5.6.23 LGPL-2 TRUE
#> 10 pkgbu… stan… FALSE FALSE OK pkgbui… 1.4.8 MIT + … FALSE
#> # ℹ 17 more rows
#> # ℹ 26 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>, sysreqs <chr>, os_type <chr>,
#> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, …
# Method download()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$download()
#> ℹ Getting 7 pkgs (3.16 MB) and 14 pkgs with unknown sizes, 6 (794.38 kB) cached
#> ✔ Cached copy of pkgdepends 0.9.1.9000 (source) is the latest build
#> ✔ Cached copy of callr 3.7.6 (source) is the latest build
#> ✔ Cached copy of curl 7.0.0 (source) is the latest build
#> ✔ Cached copy of jsonlite 2.0.0 (source) is the latest build
#> ✔ Cached copy of cli 3.6.6 (source) is the latest build
#> ✔ Cached copy of pkgcache 2.2.5 (source) is the latest build
#> ✔ Cached copy of processx 3.8.7 (source) is the latest build
#> ✔ Cached copy of ps 1.9.3 (source) is the latest build
#> ✔ Got filelock 1.0.3 (source) (24.86 kB)
#> ✔ Got R6 2.6.1 (source) (86.96 kB)
#> ✔ Got desc 1.4.3 (source) (334.44 kB)
#> ✔ Got callr 3.7.6 (source) (452.27 kB)
#> ✔ Got ps 1.9.2 (source) (508.44 kB)
#> ✔ Got lpSolve 5.6.23 (source) (376.46 kB)
#> ✔ Got curl 7.0.0 (source) (788.73 kB)
#> ✔ Got zip 2.3.3 (source) (657.82 kB)
#> ✔ Got processx 3.8.7 (source) (339.19 kB)
#> ✔ Got pkgbuild 1.4.8 (source) (209.91 kB)
#> ✔ Got cli 3.6.6 (source) (1.35 MB)
#> ✔ Got pkgcache 2.2.5 (source) (967.10 kB)
#> ✔ Got jsonlite 2.0.0 (source) (1.09 MB)
pdl$get_downloads()
#> # A data frame: 27 × 41
#> 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.9.1.… MIT + … TRUE
#> 2 R6 stan… FALSE FALSE OK R6 2.6.1 MIT + … FALSE
#> 3 callr stan… FALSE FALSE OK callr 3.7.6 MIT + … FALSE
#> 4 cli stan… FALSE FALSE OK cli 3.6.6 MIT + … TRUE
#> 5 curl stan… FALSE FALSE OK curl 7.0.0 MIT + … TRUE
#> 6 desc stan… FALSE FALSE OK desc 1.4.3 MIT + … FALSE
#> 7 filel… stan… FALSE FALSE OK filelo… 1.0.3 MIT + … TRUE
#> 8 jsonl… stan… FALSE FALSE OK jsonli… 2.0.0 MIT + … TRUE
#> 9 lpSol… stan… FALSE FALSE OK lpSolve 5.6.23 LGPL-2 TRUE
#> 10 pkgbu… stan… FALSE FALSE OK pkgbui… 1.4.8 MIT + … FALSE
#> # ℹ 17 more rows
#> # ℹ 32 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>, sysreqs <chr>, os_type <chr>,
#> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, …
# Method get_downloads()
pdl <- new_pkg_download_proposal("pkgload")
pdl$resolve()
pdl$download()
#> ℹ Getting 9 pkgs (3.59 MB) and 13 pkgs with unknown sizes, 4 (303.01 kB) cached
#> ✔ Cached copy of callr 3.7.6 (source) is the latest build
#> ✔ Cached copy of rprojroot 2.1.1 (source) is the latest build
#> ✔ Cached copy of cli 3.6.6 (source) is the latest build
#> ✔ Cached copy of fs 2.1.0 (source) is the latest build
#> ✔ Cached copy of glue 1.8.1 (source) is the latest build
#> ✔ Cached copy of pkgload 1.5.1 (source) is the latest build
#> ✔ Cached copy of processx 3.8.7 (source) is the latest build
#> ✔ Cached copy of ps 1.9.3 (source) is the latest build
#> ✔ Cached copy of rlang 1.2.0 (source) is the latest build
#> ✔ Got R6 2.6.1 (source) (86.96 kB)
#> ✔ Got desc 1.4.3 (source) (334.44 kB)
#> ✔ Got fs 2.0.1 (source) (331.80 kB)
#> ✔ Got glue 1.8.0 (source) (172.43 kB)
#> ✔ Got rprojroot 2.1.1 (source) (111.65 kB)
#> ✔ Got lifecycle 1.0.5 (source) (138.30 kB)
#> ✔ Got callr 3.7.6 (source) (452.27 kB)
#> ✔ Got cli 3.6.6 (source) (1.35 MB)
#> ✔ Got processx 3.8.7 (source) (339.19 kB)
#> ✔ Got pkgbuild 1.4.8 (source) (209.91 kB)
#> ✔ Got ps 1.9.2 (source) (508.44 kB)
#> ✔ Got rlang 1.2.0 (source) (1.62 MB)
#> ✔ Got pkgload 1.5.1 (source) (223.87 kB)
pdl$get_downloads()
#> # A data frame: 26 × 41
#> 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.6.1 MIT + … FALSE
#> 2 callr stan… FALSE FALSE OK callr 3.7.6 MIT + … FALSE
#> 3 cli stan… FALSE FALSE OK cli 3.6.6 MIT + … TRUE
#> 4 desc stan… FALSE FALSE OK desc 1.4.3 MIT + … FALSE
#> 5 fs stan… FALSE FALSE OK fs 2.0.1 MIT + … TRUE
#> 6 glue stan… FALSE FALSE OK glue 1.8.0 MIT + … TRUE
#> 7 lifec… stan… FALSE FALSE OK lifecy… 1.0.5 MIT + … FALSE
#> 8 pkgbu… stan… FALSE FALSE OK pkgbui… 1.4.8 MIT + … FALSE
#> 9 pkglo… stan… TRUE TRUE OK pkgload 1.5.1 MIT + … FALSE
#> 10 proce… stan… FALSE FALSE OK proces… 3.8.7 MIT + … TRUE
#> # ℹ 16 more rows
#> # ℹ 32 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>, sysreqs <chr>, os_type <chr>,
#> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <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 7 pkgs (3.16 MB) and 14 pkgs with unknown sizes, 6 (794.38 kB) cached
#> ✔ Cached copy of pkgdepends 0.9.1.9000 (source) is the latest build
#> ✔ Cached copy of callr 3.7.6 (source) is the latest build
#> ✔ Cached copy of curl 7.0.0 (source) is the latest build
#> ✔ Cached copy of jsonlite 2.0.0 (source) is the latest build
#> ✔ Cached copy of cli 3.6.6 (source) is the latest build
#> ✔ Cached copy of pkgcache 2.2.5 (source) is the latest build
#> ✔ Cached copy of processx 3.8.7 (source) is the latest build
#> ✔ Got R6 2.6.1 (source) (86.96 kB)
#> ✔ Got filelock 1.0.3 (source) (24.86 kB)
#> ✔ Cached copy of ps 1.9.3 (source) is the latest build
#> ✔ Got callr 3.7.6 (source) (452.27 kB)
#> ✔ Got desc 1.4.3 (source) (334.44 kB)
#> ✔ Got lpSolve 5.6.23 (source) (376.46 kB)
#> ✔ Got pkgbuild 1.4.8 (source) (209.91 kB)
#> ✔ Got zip 2.3.3 (source) (657.82 kB)
#> ✔ Got curl 7.0.0 (source) (788.73 kB)
#> ✔ Got ps 1.9.2 (source) (508.44 kB)
#> ✔ Got processx 3.8.7 (source) (339.19 kB)
#> ✔ Got cli 3.6.6 (source) (1.35 MB)
#> ✔ Got pkgcache 2.2.5 (source) (967.10 kB)
#> ✔ Got jsonlite 2.0.0 (source) (1.09 MB)
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)