Skip to content

Download packages with their dependencies, from various sources.

Usage

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
#> ## sysreqs_sudo
#> <default>
#> [1] TRUE
#> 
#> ## build_vignettes
#> <default>
#> [1] FALSE
#> 
#> ## package_cache_dir
#> <default>
#> NULL
#> 
#> ## sysreqs_rspm_repo_id
#> <default>
#> [1] "1"
#> 
#> ## sysreqs_dry_run
#> <default>
#> [1] FALSE
#> 
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/Rtmpa5gFvT/file1b924fac8d4e"
#> 
#> ## dependencies
#> <default>
#> [1] "Depends"   "Imports"   "LinkingTo"
#> 
#> ## sysreqs_rspm_url
#> <default>
#> [1] "https://packagemanager.posit.co"
#> 
#> ## sysreqs
#> <default>
#> [1] TRUE
#> 
#> ## use_bioconductor
#> <default>
#> [1] TRUE
#> 
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-22.04" "source"                          
#> 
#> ## library
#> <default>
#> NULL
#> 
#> ## windows_archs
#> <default>
#> [1] "prefer-x64"
#> 
#> ## metadata_update_after
#> <default>
#> Time difference of 24 hours
#> 
#> ## cran_mirror
#> <default>
#>                          CRAN 
#> "https://cloud.r-project.org" 
#> 
#> ## cache_dir
#> <default>
#> [1] "/tmp/Rtmpa5gFvT/file1b925c83c92d"
#> 
#> ## sysreqs_verbose
#> <default>
#> [1] TRUE
#> 
#> ## r_versions
#> <default>
#> [1] "4.2.2"
#> 
# Method resolve()
pdl <- new_pkg_download_proposal("pak")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 2 × 30
#>   ref   type     direct directpkg status package version license needsco…¹
#>   <chr> <chr>    <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>   <lgl>    
#> 1 pak   standard TRUE   TRUE      OK     pak     0.3.1   GPL-3   FALSE    
#> 2 pak   standard TRUE   TRUE      OK     pak     0.3.1   GPL-3   FALSE    
#> # … with 21 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>, cache_status <chr>, and abbreviated variable name
#> #   ¹​needscompilation
# Method get_resolution()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 39 × 30
#>    ref         type  direct direc…¹ status package version license needs…²
#>    <chr>       <chr> <lgl>  <lgl>   <chr>  <chr>   <chr>   <chr>   <lgl>  
#>  1 r-lib/pkgd… gith… TRUE   TRUE    OK     pkgdep… 0.4.0.… MIT + … TRUE   
#>  2 R6          stan… FALSE  FALSE   OK     R6      2.5.1   MIT + … FALSE  
#>  3 callr       stan… FALSE  FALSE   OK     callr   3.7.3   MIT + … FALSE  
#>  4 cli         stan… FALSE  FALSE   OK     cli     3.4.1   MIT + … TRUE   
#>  5 crayon      stan… FALSE  FALSE   OK     crayon  1.5.2   MIT + … FALSE  
#>  6 curl        stan… FALSE  FALSE   OK     curl    4.3.3   MIT + … TRUE   
#>  7 desc        stan… FALSE  FALSE   OK     desc    1.4.2   MIT + … FALSE  
#>  8 filelock    stan… FALSE  FALSE   OK     filelo… 1.0.2   MIT + … TRUE   
#>  9 glue        stan… FALSE  FALSE   OK     glue    1.6.2   MIT + … TRUE   
#> 10 jsonlite    stan… FALSE  FALSE   OK     jsonli… 1.8.4   MIT + … TRUE   
#> # … with 29 more rows, 21 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>, cache_status <chr>, and abbreviated
#> #   variable names ¹​directpkg, ²​needscompilation
# Method download()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$download()
#>  Getting 38 pkgs (7.98 MB) and 1 pkg with unknown size
#>  Got crayon 1.5.2 (source) (40.57 kB)
#>  Got callr 3.7.3 (source) (97.81 kB)
#>  Got desc 1.4.2 (source) (79.25 kB)
#>  Got filelock 1.0.2 (source) (12.38 kB)
#>  Got prettyunits 1.1.1 (source) (10.37 kB)
#>  Got processx 3.8.0 (source) (162.54 kB)
#>  Got zip 2.2.2 (source) (103.40 kB)
#>  Got rprojroot 2.0.3 (source) (59.94 kB)
#>  Got glue 1.6.2 (source) (106.51 kB)
#>  Got R6 2.5.1 (source) (2.66 kB)
#>  Got crayon 1.5.2 (source) (158.60 kB)
#>  Got R6 2.5.1 (source) (2.66 kB)
#>  Got rappdirs 0.3.3 (source) (12.29 kB)
#>  Got ps 1.7.2 (source) (129.10 kB)
#>  Got cli 3.4.1 (source) (866.76 kB)
#>  Got desc 1.4.2 (source) (319.94 kB)
#>  Got pkgbuild 1.4.0 (source) (43.74 kB)
#>  Got glue 1.6.2 (source) (154.76 kB)
#>  Got callr 3.7.3 (source) (425.23 kB)
#>  Got filelock 1.0.2 (source) (30.53 kB)
#>  Got pkgcache 2.0.4 (source) (236.94 kB)
#>  Got withr 2.5.0 (source) (102.09 kB)
#>  Got prettyunits 1.1.1 (source) (34.32 kB)
#>  Got curl 4.3.3 (source) (91.57 kB)
#>  Got processx 3.8.0 (source) (431.18 kB)
#>  Got lpSolve 5.6.17 (source) (690.99 kB)
#>  Got curl 4.3.3 (source) (91.57 kB)
#>  Got rprojroot 2.0.3 (source) (101.42 kB)
#>  Got withr 2.5.0 (source) (225.66 kB)
#>  Got jsonlite 1.8.4 (source) (1.67 MB)
#>  Got pkgbuild 1.4.0 (source) (176.29 kB)
#>  Got ps 1.7.2 (source) (381.92 kB)
#>  Got rappdirs 0.3.3 (source) (45.78 kB)
#>  Got cli 3.4.1 (source) (962.50 kB)
#>  Got jsonlite 1.8.4 (source) (471.70 kB)
#>  Got pkgcache 2.0.3 (source) (796.41 kB)
#>  Got lpSolve 5.6.17 (source) (1.01 MB)
#>  Got zip 2.2.2 (source) (621.30 kB)
#>  Got pkgdepends 0.4.0.9000 (source) (492.54 kB)
pdl$get_downloads()
#> # A data frame: 39 × 35
#>    ref         type  direct direc…¹ status package version license needs…²
#>    <chr>       <chr> <lgl>  <lgl>   <chr>  <chr>   <chr>   <chr>   <lgl>  
#>  1 r-lib/pkgd… gith… TRUE   TRUE    OK     pkgdep… 0.4.0.… MIT + … TRUE   
#>  2 R6          stan… FALSE  FALSE   OK     R6      2.5.1   MIT + … FALSE  
#>  3 callr       stan… FALSE  FALSE   OK     callr   3.7.3   MIT + … FALSE  
#>  4 cli         stan… FALSE  FALSE   OK     cli     3.4.1   MIT + … TRUE   
#>  5 crayon      stan… FALSE  FALSE   OK     crayon  1.5.2   MIT + … FALSE  
#>  6 curl        stan… FALSE  FALSE   OK     curl    4.3.3   MIT + … TRUE   
#>  7 desc        stan… FALSE  FALSE   OK     desc    1.4.2   MIT + … FALSE  
#>  8 filelock    stan… FALSE  FALSE   OK     filelo… 1.0.2   MIT + … TRUE   
#>  9 glue        stan… FALSE  FALSE   OK     glue    1.6.2   MIT + … TRUE   
#> 10 jsonlite    stan… FALSE  FALSE   OK     jsonli… 1.8.4   MIT + … TRUE   
#> # … with 29 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>, cache_status <chr>, fulltarget <chr>,
#> #   fulltarget_tree <chr>, download_status <chr>, …
# Method get_downloads()
pdl <- new_pkg_download_proposal("pkgload")
pdl$resolve()
pdl$download()
#>  Getting 10 pkgs (4.43 MB), 10 (776.71 kB) cached
#>  Cached copy of R6 2.5.1 (source) is the latest build
#>  Cached copy of cli 3.4.1 (source) is the latest build
#>  Cached copy of cli 3.4.1 (source) is the latest build
#>  Cached copy of R6 2.5.1 (source) is the latest build
#>  Got pkgload 1.3.2 (source) (76.70 kB)
#>  Got rlang 1.0.6 (source) (810.45 kB)
#>  Got fs 1.5.2 (source) (1.27 MB)
#>  Got fs 1.5.2 (source) (258.86 kB)
#>  Got pkgload 1.3.2 (source) (173.40 kB)
#>  Got rlang 1.0.6 (source) (1.86 MB)
pdl$get_downloads()
#> # A data frame: 20 × 35
#>    ref       type    direct direc…¹ status package version license needs…²
#>    <chr>     <chr>   <lgl>  <lgl>   <chr>  <chr>   <chr>   <chr>   <lgl>  
#>  1 R6        standa… FALSE  FALSE   OK     R6      2.5.1   MIT + … FALSE  
#>  2 cli       standa… FALSE  FALSE   OK     cli     3.4.1   MIT + … TRUE   
#>  3 crayon    standa… FALSE  FALSE   OK     crayon  1.5.2   MIT + … FALSE  
#>  4 desc      standa… FALSE  FALSE   OK     desc    1.4.2   MIT + … FALSE  
#>  5 fs        standa… FALSE  FALSE   OK     fs      1.5.2   MIT + … TRUE   
#>  6 glue      standa… FALSE  FALSE   OK     glue    1.6.2   MIT + … TRUE   
#>  7 pkgload   standa… TRUE   TRUE    OK     pkgload 1.3.2   GPL-3   FALSE  
#>  8 rlang     standa… FALSE  FALSE   OK     rlang   1.0.6   MIT + … TRUE   
#>  9 rprojroot standa… FALSE  FALSE   OK     rprojr… 2.0.3   MIT + … FALSE  
#> 10 withr     standa… FALSE  FALSE   OK     withr   2.5.0   MIT + … FALSE  
#> 11 cli       standa… FALSE  FALSE   OK     cli     3.4.1   MIT + … TRUE   
#> 12 crayon    standa… FALSE  FALSE   OK     crayon  1.5.2   MIT + … FALSE  
#> 13 desc      standa… FALSE  FALSE   OK     desc    1.4.2   MIT + … FALSE  
#> 14 fs        standa… FALSE  FALSE   OK     fs      1.5.2   MIT + … TRUE   
#> 15 glue      standa… FALSE  FALSE   OK     glue    1.6.2   MIT + … TRUE   
#> 16 pkgload   standa… TRUE   TRUE    OK     pkgload 1.3.2   GPL-3   FALSE  
#> 17 R6        standa… FALSE  FALSE   OK     R6      2.5.1   MIT + … FALSE  
#> 18 rlang     standa… FALSE  FALSE   OK     rlang   1.0.6   MIT + … TRUE   
#> 19 rprojroot standa… FALSE  FALSE   OK     rprojr… 2.0.3   MIT + … FALSE  
#> 20 withr     standa… FALSE  FALSE   OK     withr   2.5.0   MIT + … FALSE  
#> # … with 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>, cache_status <chr>, fulltarget <chr>,
#> #   fulltarget_tree <chr>, download_status <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 (+19 dependencies)
#> (use `$download()` to download packages)
#> (use `$get_resolution()` to see resolution results)

pdl$download()
#>  Getting 12 pkgs (6.06 MB) and 1 pkg with unknown size, 26 (1.92 MB) cached
#>  Cached copy of pkgdepends 0.4.0.9000 (source) is the latest build
#>  Cached copy of R6 2.5.1 (source) is the latest build
#>  Cached copy of cli 3.4.1 (source) is the latest build
#>  Cached copy of curl 4.3.3 (source) is the latest build
#>  Cached copy of jsonlite 1.8.4 (source) is the latest build
#>  Cached copy of lpSolve 5.6.17 (source) is the latest build
#>  Cached copy of pkgcache 2.0.3 (source) is the latest build
#>  Cached copy of cli 3.4.1 (source) is the latest build
#>  Cached copy of curl 4.3.3 (source) is the latest build
#>  Cached copy of jsonlite 1.8.4 (source) is the latest build
#>  Cached copy of lpSolve 5.6.17 (source) is the latest build
#>  Cached copy of pkgcache 2.0.4 (source) is the latest build
#>  Cached copy of R6 2.5.1 (source) is the latest build
pdl
#> <pkg_download_proposal>
#> + refs:
#>   - r-lib/pkgdepends
#> + has resolution (+19 dependencies)
#> + has downloads
#> (use `$get_resolution()` to see resolution results)
#> (use `$get_downloads()` to get download data)