new_pkg_installation_proposal | R Documentation |
Download and install R packages, with their dependencies, from various sources.
new_pkg_installation_proposal(refs, config = list(), ...)
refs |
Package names or references. See 'Package references' for the syntax. |
config |
Configuration options, a named list. See
'Configuration'. If it does not include |
... |
Additional arguments, passed to
|
new_pkg_installation_proposal()
creates a new object from the
pkg_installation_proposal
class. The advantage of
new_pkg_installation_proposal()
compared to using the
pkg_installation_proposal constructor directly is that it avoids
making pkgdepends a build time dependency.
Typical workflow to install a set of packages:
Create a pkg_installation_proposal
object with
new_pkg_installation_proposal()
.
Resolve all possible dependencies with
pkg_installation_proposal$resolve()
.
Solve the package dependencies, to get an installation plan, with
pkg_installation_proposal$solve()
.
Download all files with
pkg_installation_proposal$download()
.
Install the downloaded files with
pkg_installation_proposal$install()
.
new_pkg_installation_proposal()
returns a new
pkg_installation_proposal
object.
new()
Create a new pkg_installation_proposal
object. Consider using
new_pkg_installation_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 download and install the package files.
pkg_installation_proposal$new( refs, config = list(), policy = c("lazy", "upgrade"), remote_types = NULL )
refs
Package names or references. See 'Package references' for the syntax.
config
Configuration options, a named list. See
'Configuration'. It needs to include the package
library to install to, in library
.
policy
Solution policy. See 'The dependency solver'.
remote_types
Custom remote ref types, this is for advanced use, and experimental currently.
get_refs()
The package refs that were used to create the
pkg_installation_proposal
object.
pkg_installation_proposal$get_refs()
A character vector of package refs that were used to create the
pkg_installation_proposal
object.
get_config()
Configuration options for the pkg_installation_proposal
object. See
'Configuration' for details.
pkg_installation_proposal$get_config()
Named list. See 'Configuration' for the configuration options.
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.
pkg_installation_proposal$resolve()
The pkg_installation_proposal
object, invisibly.
\dontrun{ pdi <- new_pkg_installation_proposal( "pak", config = list(library = tempfile()) ) pdi$resolve() pdi$get_resolution() }
async_resolve()
The same as resolve()
, but asynchronous. This
method is for advanced use.
pkg_installation_proposal$async_resolve()
A deferred value.
get_resolution()
Query the result of the dependency resolution. This method can be
called after resolve()
has completed.
pkg_installation_proposal$get_resolution()
A pkg_resolution_result object, which is also a data frame. See 'Dependency resolution' for its columns.
\dontrun{ pdi <- new_pkg_installation_proposal( "r-lib/pkgdepends", config = list(library = tempfile()) ) pdi$resolve() pdi$get_resolution() }
get_solve_policy()
Returns the current policy of the dependency solver. See 'The dependency solver' for details.
pkg_installation_proposal$get_solve_policy()
A character vector of length one.
set_solve_policy()
Set the current policy of the dependency solver. If the object already contains a solution and the new policy is different than the old policy, then the solution is deleted. See 'The dependency solver' for details.
pkg_installation_proposal$set_solve_policy(policy = c("lazy", "upgrade"))
policy
Policy to set.
solve()
Solve the package dependencies. Out of the resolved dependencies, it works out a set of packages, that can be installed together to create a functional installation. The set includes all directly specified packages, and all required (or suggested, depending on the configuration) packages as well. It includes every package at most once. See 'The dependency solver' for details.
pkg_installation_proposal$solve()
The pkg_installation_proposal
object itself, invisibly.
\dontrun{ pdi <- new_pkg_installation_proposal( "r-lib/pkgdepends", config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$get_solution() }
get_solution()
Returns the solution of the package dependencies.
pkg_installation_proposal$get_solution()
A pkg_solution_result object, which is a list. See pkg_solution_result for details.
\dontrun{ pdi <- new_pkg_installation_proposal( "r-lib/pkgdepends", config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$get_solution() }
show_solution()
Show the solution on the screen.
pkg_installation_proposal$show_solution(key = FALSE)
key
Whether to show the key to the package list annotation.
A pkg_solution_result object, which is a list. See pkg_solution_result for details.
\dontrun{ pdi <- new_pkg_installation_proposal( "r-lib/pkgdepends", config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$get_solution() pdi$show_solution() }
get_sysreqs()
Query and categorize system requirements.
pkg_installation_proposal$get_sysreqs()
show_sysreqs()
Show system requirements for the packages in the solution.
pkg_installation_proposal$show_sysreqs()
stop_for_solution_error()
Error if the dependency solver failed to find a consistent set of packages that can be installed together.
pkg_installation_proposal$stop_for_solution_error()
\dontrun{ # This is an error, because the packages conflict: pdi <- new_pkg_installation_proposal( c("r-lib/pak", "cran::pak"), config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi # This fails: # pdi$stop_for_solution_error() }
create_lockfile()
Create a lock file that contains the information to perform the installation later, possibly in another R session.
pkg_installation_proposal$create_lockfile(path = "pkg.lock", version = 1)
path
Name of the lock file. The default is pkg.lock
in the
current working directory.
version
Only version 1 is supported currently.
Note, since the URLs of CRAN and most CRAN-like repositories change over time, in practice you cannot perform the plan of the lock file much later. For example, binary packages of older package version are removed, and won't be found.
Similarly, for url::
remote types, the URL might hold an updated
version of the package, compared to when the lock file was created.
Should this happen, pkgdepends prints a warning, but it will try
to continue the installation. The installation might fail if the
updated package has different (e.g. new) dependencies.
Currently the intended use case of lock files in on CI systems, to facilitate caching. The (hash of the) lock file provides a good key for caching systems.
draw()
Draw a tree of package dependencies. It returns a tree
object, see
cli::tree()
. Printing this object prints the dependency tree to the
screen.
pkg_installation_proposal$draw()
A tree
object from the cli package, see cli::tree()
.
\dontrun{ pdi <- new_pkg_installation_proposal( "pak", config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$draw() }
download()
Download all packages that are part of the solution. It uses the package cache in the pkgcache package by default, to avoid downloads if possible.
pkg_installation_proposal$download()
The pkg_installation_proposal
object itself, invisibly.
\dontrun{ pdi <- new_pkg_installation_proposal( c("r-lib/pak", "cran::pak"), config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$download() pdi$get_downloads() }
async_download()
The same as download()
, but asynchronous.
This method is for advanced use.
pkg_installation_proposal$async_download()
A deferred value.
get_downloads()
Returns the summary of the package downloads.
pkg_installation_proposal$get_downloads()
A pkg_download_result object, which is a list. See pkg_download_result for details.
\dontrun{ pdi <- new_pkg_installation_proposal( c("r-lib/pak", "cran::pak"), config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$download() pdi$get_downloads() }
stop_for_download_error()
Throw and error if the some of the downloads have failed for the
most recent
pkg_installation_proposal$download()
call.
pkg_installation_proposal$stop_for_download_error()
install()
Install the downloaded packages. It calls install_package_plan()
.
pkg_installation_proposal$install()
The return value of install_package_plan()
.
install_sysreqs()
Install system requirements. It does nothing if system requirements are turned off. Create an installation plan for the downloaded packages.
pkg_installation_proposal$install_sysreqs()
get_install_plan()
pkg_installation_proposal$get_install_plan()
An installation plan, see 'Installation plans' for the format.
\dontrun{ pdi <- new_pkg_installation_proposal( "pak", config = list(library = tempfile()) ) pdi$resolve() pdi$solve() pdi$download() pdi$get_install_plan() }
format()
Format a pkg_installation_proposal
object, typically for printing.
pkg_installation_proposal$format(...)
...
not used currently.
A character vector, each element should be a line in the printout.
print()
Prints a pkg_installation_proposal
object to the screen.
The printout includes:
The package refs.
The policy of the dependency solver.
Whether the object has the solved dependencies.
Whether the solution had errors.
Whether the object has downloads.
Whether the downloads had errors.
Advice on which methods to call next.
See the example below.
pkg_installation_proposal$print(...)
...
not used currently.
The pkg_installation_proposal
object itself, invisibly.
clone()
The objects of this class are cloneable with this method.
pkg_installation_proposal$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run:
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi
pdi$resolve()
pdi
pdi$solve()
pdi
pdi$download()
pdi
## End(Not run)
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile()))
pdi
pdi <- new_pkg_installation_proposal("r-lib/pkgdepends")
pdi$get_refs()
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi$get_config()
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$get_solve_policy()
pdi$set_solve_policy("upgrade")
pdi$get_solve_policy()
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$get_solve_policy()
pdi$set_solve_policy("upgrade")
pdi$get_solve_policy()
# Method print
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi
pdi$resolve()
pdi
pdi$solve()
pdi
pdi$download()
pdi
## ------------------------------------------------
## Method `pkg_installation_proposal$resolve`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi$resolve()
pdi$get_resolution()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$get_resolution`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$resolve()
pdi$get_resolution()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$solve`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$get_solution()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$get_solution`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$get_solution()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$show_solution`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"r-lib/pkgdepends",
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$get_solution()
pdi$show_solution()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$stop_for_solution_error`
## ------------------------------------------------
## Not run:
# This is an error, because the packages conflict:
pdi <- new_pkg_installation_proposal(
c("r-lib/pak", "cran::pak"),
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi
# This fails:
# pdi$stop_for_solution_error()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$draw`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$draw()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$download`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
c("r-lib/pak", "cran::pak"),
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$download()
pdi$get_downloads()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$get_downloads`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
c("r-lib/pak", "cran::pak"),
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$download()
pdi$get_downloads()
## End(Not run)
## ------------------------------------------------
## Method `pkg_installation_proposal$get_install_plan`
## ------------------------------------------------
## Not run:
pdi <- new_pkg_installation_proposal(
"pak",
config = list(library = tempfile())
)
pdi$resolve()
pdi$solve()
pdi$download()
pdi$get_install_plan()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.