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


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 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.

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()
#> # pkg config
#> ## build_vignettes
#> <default>
#> [1] FALSE
#> 
#> ## sysreqs_verbose
#> <default>
#> [1] FALSE
#> 
#> ## sysreqs_db_update
#> <default>
#> [1] TRUE
#> 
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/Rtmp12qniL/file36a7f1866da3c"
#> 
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-22.04" "source"                          
#> 
#> ## goal
#> <default>
#> [1] "unknown"
#> 
#> ## r_versions
#> <default>
#> [1] "4.4.1"
#> 
#> ## cache_dir
#> <default>
#> [1] "/tmp/Rtmp12qniL/file36a7f171100f4e"
#> 
#> ## 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-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://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.8.0   GPL-3   FALSE           
#> 2 pak   standa… TRUE   TRUE      OK     pak     0.9.0   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.0.… MIT + … TRUE            
#>  2 callr  stan… FALSE  FALSE     OK     callr   3.7.6   MIT + … FALSE           
#>  3 cli    stan… FALSE  FALSE     OK     cli     3.6.3   MIT + … FALSE           
#>  4 curl   stan… FALSE  FALSE     OK     curl    5.2.3   MIT + … FALSE           
#>  5 desc   stan… FALSE  FALSE     OK     desc    1.4.3   MIT + … FALSE           
#>  6 filel… stan… FALSE  FALSE     OK     filelo… 1.0.3   MIT + … FALSE           
#>  7 jsonl… stan… FALSE  FALSE     OK     jsonli… 1.8.9   MIT + … FALSE           
#>  8 lpSol… stan… FALSE  FALSE     OK     lpSolve 5.6.21  LGPL-2  FALSE           
#>  9 pkgbu… stan… FALSE  FALSE     OK     pkgbui… 1.4.4   MIT + … FALSE           
#> 10 pkgca… stan… FALSE  FALSE     OK     pkgcac… 2.2.3   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()
#>  No downloads are needed, 27 pkgs (4.15 MB) are cached
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.0.… MIT + … TRUE            
#>  2 callr  stan… FALSE  FALSE     OK     callr   3.7.6   MIT + … FALSE           
#>  3 cli    stan… FALSE  FALSE     OK     cli     3.6.3   MIT + … FALSE           
#>  4 curl   stan… FALSE  FALSE     OK     curl    5.2.3   MIT + … FALSE           
#>  5 desc   stan… FALSE  FALSE     OK     desc    1.4.3   MIT + … FALSE           
#>  6 filel… stan… FALSE  FALSE     OK     filelo… 1.0.3   MIT + … FALSE           
#>  7 jsonl… stan… FALSE  FALSE     OK     jsonli… 1.8.9   MIT + … FALSE           
#>  8 lpSol… stan… FALSE  FALSE     OK     lpSolve 5.6.21  LGPL-2  FALSE           
#>  9 pkgbu… stan… FALSE  FALSE     OK     pkgbui… 1.4.4   MIT + … FALSE           
#> 10 pkgca… stan… FALSE  FALSE     OK     pkgcac… 2.2.3   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()
#>  No downloads are needed, 28 pkgs (3.73 MB) are cached
pdl$get_downloads()
#> # A data frame: 28 × 41
#>    ref    type  direct directpkg status package version license needscompilation
#>    <chr>  <chr> <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>   <lgl>           
#>  1 callr  stan… FALSE  FALSE     OK     callr   3.7.6   MIT + … FALSE           
#>  2 cli    stan… FALSE  FALSE     OK     cli     3.6.3   MIT + … FALSE           
#>  3 desc   stan… FALSE  FALSE     OK     desc    1.4.3   MIT + … FALSE           
#>  4 fs     stan… FALSE  FALSE     OK     fs      1.6.4   MIT + … FALSE           
#>  5 glue   stan… FALSE  FALSE     OK     glue    1.8.0   MIT + … FALSE           
#>  6 lifec… stan… FALSE  FALSE     OK     lifecy… 1.0.4   MIT + … FALSE           
#>  7 pkgbu… stan… FALSE  FALSE     OK     pkgbui… 1.4.4   MIT + … FALSE           
#>  8 pkglo… stan… TRUE   TRUE      OK     pkgload 1.4.0   GPL-3   FALSE           
#>  9 proce… stan… FALSE  FALSE     OK     proces… 3.8.4   MIT + … FALSE           
#> 10 ps     stan… FALSE  FALSE     OK     ps      1.8.0   MIT + … FALSE           
#> # ℹ 18 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()
#>  No downloads are needed, 27 pkgs (4.15 MB) are cached
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)