parse_installed {pkgcache} | R Documentation |
List metadata of installed packages
Description
This function is similar to utils::installed.packages()
.
See the differences below.
Usage
parse_installed(
library = .libPaths(),
priority = NULL,
lowercase = FALSE,
reencode = TRUE,
packages = NULL
)
Arguments
library |
Character vector of library paths. |
priority |
If not |
lowercase |
Whether to convert keys in |
reencode |
Whether to re-encode strings in UTF-8, from the
encodings specified in the |
packages |
If not |
Details
Differences with utils::installed.packages()
:
-
parse_installed()
cannot subset the extracted fields. (But you can subset the result.) -
parse_installed()
does not cache the results. -
parse_installed()
handles errors better. See Section 'Errors' below. #' *parse_installed()
uses theDESCRIPTION
files in the installed packages instead of theMeta/package.rds
files. This should not matter, but because of a bugMeta/package.rds
might contain the wrongArchs
field on multi-arch platforms. -
parse_installed()
reads all fields from theDESCRIPTION
files.utils::installed.packages()
only reads the specified fields. -
parse_installed()
converts its output to UTF-8 encoding, from the encodings declared in theDESCRIPTION
files. -
parse_installed()
is considerably faster.
Encodings
parse_installed()
always returns its result in UTF-8 encoding.
It uses the Encoding
fields in the DESCRIPTION
files to learn their
encodings. parse_installed()
does not check that an UTF-8 file has a
valid encoding. If it fails to convert a string to UTF-8 from another
declared encoding, then it leaves it as "bytes"
encoded, without a
warning.
Errors
pkgcache silently ignores files and directories inside the library directory.
The result also omits broken package installations. These include
packages with invalid
DESCRIPTION
files, andpackages the current user have no access to.
These errors are reported via a condition with class
pkgcache_broken_install
. The condition has an errors
entry, which
is a data frame with columns
-
file
: path to theDESCRIPTION
file of the broken package, -
error
: error message for this particular failure.
If you intend to handle broken package installation, you need to catch
this condition with withCallingHandlers()
.