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
#> ## build_vignettes
#> <default>
#> [1] FALSE
#> 
#> ## sysreqs_verbose
#> <default>
#> [1] TRUE
#> 
#> ## sysreqs_db_update
#> <default>
#> [1] TRUE
#> 
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/RtmpIF0ENc/file1af13ca9e1bc"
#> 
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-22.04" "source"                          
#> 
#> ## goal
#> <default>
#> [1] "unknown"
#> 
#> ## r_versions
#> <default>
#> [1] "4.3.1"
#> 
#> ## cache_dir
#> <default>
#> [1] "/tmp/RtmpIF0ENc/file1af11fcbdf22"
#> 
#> ## 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
#> 
#> ## 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 × 34
#>   ref   type     direct directpkg status package version license
#>   <chr> <chr>    <lgl>  <lgl>     <chr>  <chr>   <chr>   <chr>  
#> 1 pak   standard TRUE   TRUE      OK     pak     0.5.1   GPL-3  
#> 2 pak   standard TRUE   TRUE      OK     pak     0.5.1   GPL-3  
#> # ℹ 26 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>, cache_status <chr>,
#> #   sysreqs_packages <list>, sysreqs_pre_install <chr>, …
# Method get_resolution()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 37 × 34
#>    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.6.0.… MIT + …
#>  2 R6               stand… FALSE  FALSE     OK     R6      2.5.1   MIT + …
#>  3 callr            stand… FALSE  FALSE     OK     callr   3.7.3   MIT + …
#>  4 cli              stand… FALSE  FALSE     OK     cli     3.6.1   MIT + …
#>  5 crayon           stand… FALSE  FALSE     OK     crayon  1.5.2   MIT + …
#>  6 curl             stand… FALSE  FALSE     OK     curl    5.0.1   MIT + …
#>  7 desc             stand… FALSE  FALSE     OK     desc    1.4.2   MIT + …
#>  8 filelock         stand… FALSE  FALSE     OK     filelo… 1.0.2   MIT + …
#>  9 glue             stand… FALSE  FALSE     OK     glue    1.6.2   MIT + …
#> 10 jsonlite         stand… FALSE  FALSE     OK     jsonli… 1.8.7   MIT + …
#> # ℹ 27 more rows
#> # ℹ 26 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>, cache_status <chr>, …
# Method download()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$download()
#>  Getting 18 pkgs (3.99 MB) and 19 pkgs with unknown sizes
#>  Got filelock 1.0.2 (source) (12.38 kB)
#>  Got crayon 1.5.2 (source) (40.57 kB)
#>  Got callr 3.7.3 (source) (97.81 kB)
#>  Got pkgbuild 1.4.2 (source) (46.95 kB)
#>  Got rappdirs 0.3.3 (source) (12.29 kB)
#>  Got desc 1.4.2 (source) (79.25 kB)
#>  Got prettyunits 1.1.1 (source) (10.37 kB)
#>  Got R6 2.5.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (82.53 kB)
#>  Got rprojroot 2.0.3 (source) (59.94 kB)
#>  Got crayon 1.5.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (159.79 kB)
#>  Got ps 1.7.5 (source) (129.21 kB)
#>  Got filelock 1.0.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (21.81 kB)
#>  Got R6 2.5.1 (source) (63.42 kB)
#>  Got desc 1.4.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (323.92 kB)
#>  Got glue 1.6.2 (source) (106.51 kB)
#>  Got zip 2.3.0 (source) (110.49 kB)
#>  Got rprojroot 2.0.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (101.20 kB)
#>  Got cli 3.6.1 (source) (567.29 kB)
#>  Got ps 1.7.5 (x86_64-pc-linux-gnu-ubuntu-22.04) (383.87 kB)
#>  Got callr 3.7.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (428.28 kB)
#>  Got pkgcache 2.2.0.1 (source) (265.86 kB)
#>  Got processx 3.8.2 (source) (163.56 kB)
#>  Got pkgbuild 1.4.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (190.02 kB)
#>  Got curl 5.0.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (762.86 kB)
#>  Got lpSolve 5.6.18 (source) (467.99 kB)
#>  Got zip 2.3.0 (x86_64-pc-linux-gnu-ubuntu-22.04) (632.14 kB)
#>  Got lpSolve 5.6.18 (x86_64-pc-linux-gnu-ubuntu-22.04) (372.70 kB)
#>  Got glue 1.6.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (146.91 kB)
#>  Got prettyunits 1.1.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (34.49 kB)
#>  Got rappdirs 0.3.3 (x86_64-pc-linux-gnu-ubuntu-22.04) (43.88 kB)
#>  Got processx 3.8.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (436.39 kB)
#>  Got jsonlite 1.8.7 (source) (1.05 MB)
#>  Got curl 5.0.1 (source) (714.18 kB)
#>  Got cli 3.6.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.27 MB)
#>  Got pkgcache 2.1.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (822.67 kB)
#>  Got jsonlite 1.8.7 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.09 MB)
#>  Got pkgdepends 0.6.0.9000 (source) (652.26 kB)
pdl$get_downloads()
#> # A data frame: 37 × 39
#>    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.6.0.… MIT + …
#>  2 R6               stand… FALSE  FALSE     OK     R6      2.5.1   MIT + …
#>  3 callr            stand… FALSE  FALSE     OK     callr   3.7.3   MIT + …
#>  4 cli              stand… FALSE  FALSE     OK     cli     3.6.1   MIT + …
#>  5 crayon           stand… FALSE  FALSE     OK     crayon  1.5.2   MIT + …
#>  6 curl             stand… FALSE  FALSE     OK     curl    5.0.1   MIT + …
#>  7 desc             stand… FALSE  FALSE     OK     desc    1.4.2   MIT + …
#>  8 filelock         stand… FALSE  FALSE     OK     filelo… 1.0.2   MIT + …
#>  9 glue             stand… FALSE  FALSE     OK     glue    1.6.2   MIT + …
#> 10 jsonlite         stand… FALSE  FALSE     OK     jsonli… 1.8.7   MIT + …
#> # ℹ 27 more rows
#> # ℹ 31 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>, cache_status <chr>, …
# Method get_downloads()
pdl <- new_pkg_download_proposal("pkgload")
pdl$resolve()
pdl$download()
#>  Getting 4 pkgs (2.13 MB) and 10 pkgs with unknown sizes, 6 (916.98 kB) cached
#>  Got pkgload 1.3.2.1 (source) (76.73 kB)
#>  Got withr 2.5.0 (source) (102.09 kB)
#>  Cached copy of glue 1.6.2 (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
#>  Cached copy of cli 3.6.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of crayon 1.5.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of desc 1.4.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of rprojroot 2.0.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Got pkgload 1.3.2.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (176.40 kB)
#>  Got withr 2.5.0 (x86_64-pc-linux-gnu-ubuntu-22.04) (228.73 kB)
#>  Got fs 1.6.2 (x86_64-pc-linux-gnu-ubuntu-22.04) (286.43 kB)
#>  Got rlang 1.1.1 (source) (762.53 kB)
#>  Got fs 1.6.2 (source) (1.19 MB)
#>  Got rlang 1.1.1 (x86_64-pc-linux-gnu-ubuntu-22.04) (1.54 MB)
pdl$get_downloads()
#> # A data frame: 20 × 39
#>    ref       type     direct directpkg status package   version license   
#>    <chr>     <chr>    <lgl>  <lgl>     <chr>  <chr>     <chr>   <chr>     
#>  1 R6        standard FALSE  FALSE     OK     R6        2.5.1   MIT + fil…
#>  2 cli       standard FALSE  FALSE     OK     cli       3.6.1   MIT + fil…
#>  3 crayon    standard FALSE  FALSE     OK     crayon    1.5.2   MIT + fil…
#>  4 desc      standard FALSE  FALSE     OK     desc      1.4.2   MIT + fil…
#>  5 fs        standard FALSE  FALSE     OK     fs        1.6.2   MIT + fil…
#>  6 glue      standard FALSE  FALSE     OK     glue      1.6.2   MIT + fil…
#>  7 pkgload   standard TRUE   TRUE      OK     pkgload   1.3.2.1 GPL-3     
#>  8 rlang     standard FALSE  FALSE     OK     rlang     1.1.1   MIT + fil…
#>  9 rprojroot standard FALSE  FALSE     OK     rprojroot 2.0.3   MIT + fil…
#> 10 withr     standard FALSE  FALSE     OK     withr     2.5.0   MIT + fil…
#> 11 cli       standard FALSE  FALSE     OK     cli       3.6.1   MIT + fil…
#> 12 crayon    standard FALSE  FALSE     OK     crayon    1.5.2   MIT + fil…
#> 13 desc      standard FALSE  FALSE     OK     desc      1.4.2   MIT + fil…
#> 14 fs        standard FALSE  FALSE     OK     fs        1.6.2   MIT + fil…
#> 15 glue      standard FALSE  FALSE     OK     glue      1.6.2   MIT + fil…
#> 16 pkgload   standard TRUE   TRUE      OK     pkgload   1.3.2.1 GPL-3     
#> 17 R6        standard FALSE  FALSE     OK     R6        2.5.1   MIT + fil…
#> 18 rlang     standard FALSE  FALSE     OK     rlang     1.1.1   MIT + fil…
#> 19 rprojroot standard FALSE  FALSE     OK     rprojroot 2.0.3   MIT + fil…
#> 20 withr     standard FALSE  FALSE     OK     withr     2.5.0   MIT + fil…
#> # ℹ 31 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>, 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 (+18 dependencies)
#> (use `$download()` to download packages)
#> (use `$get_resolution()` to see resolution results)

pdl$download()
#>  Getting 1 pkg (258.28 kB) and 19 pkgs with unknown sizes, 17 (3.74 MB) cached
#>  Cached copy of pkgdepends 0.6.0.9000 (source) is the latest build
#>  Cached copy of pkgcache 2.2.0.1 (source) is the latest build
#>  Cached copy of R6 2.5.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of cli 3.6.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of callr 3.7.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of crayon 1.5.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of curl 5.0.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of desc 1.4.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of filelock 1.0.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of jsonlite 1.8.7 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of pkgbuild 1.4.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of pkgcache 2.1.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of prettyunits 1.1.1 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of processx 3.8.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of ps 1.7.5 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of rappdirs 0.3.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of rprojroot 2.0.3 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of zip 2.3.0 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of lpSolve 5.6.18 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
#>  Cached copy of glue 1.6.2 (x86_64-pc-linux-gnu-ubuntu-22.04) is the latest build
pdl
#> <pkg_download_proposal>
#> + refs:
#>   - r-lib/pkgdepends
#> + has resolution (+18 dependencies)
#> + has downloads
#> (use `$get_resolution()` to see resolution results)
#> (use `$get_downloads()` to get download data)