Skip to content

The lock file can be used later, possibly in a new R session, to carry out the installation of the dependencies, with lockfile_install().


  pkg = "deps::.",
  lockfile = "pkg.lock",
  lib = NULL,
  upgrade = FALSE,
  dependencies = NA



Package names or remote package specifications to install. See pak package sources for details.


Path to the lock file.


Package library to install the packages to. Note that all dependent packages will the be installed here, even if they are already installed in another library.


When FALSE, the default, does the minimum amount of work to give you the latest version of pkg. It will only upgrade packages if pkg, or one of its dependencies, explicitly requires a higher version than what you currently have.

When upgrade = TRUE, will do ensure that you have the latest version of pkg and all its dependencies.


Dependency types. See pkgdepends::as_pkg_dependencies() for possible values. Note that changing this argument from the default might result an installation failure, e.g. if you set it to FALSE, packages might not build if their dependencies are not already installed.


Note, since the URLs of CRAN and most CRAN-like repositories change over time, in practice you cannot use the lock file much later. For example, binary packages of older package version might be deleted from the repository, breaking the URLs in the lock file.

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.

See also

Other lock files: lockfile_install()