Skip to content

Lint "pkg" %in% installed.packages() #2932

@Bisaloo

Description

@Bisaloo
lintr::lint(
  text = '"pkg" %in% installed.packages()', 
  linters = lintr::all_linters()
)
#> ℹ No lints found.

Created on 2025-09-16 with reprex v2.1.1

installed.packages() can be pretty slow, as noted in the documentation:

This needs to read several files per installed package, which will be slow on Windows and on some network-mounted file systems.

It will be slow when thousands of packages are installed, so do not use it to find out if a named package is installed (use find.package or system.file) nor to find out if a package is usable (call requireNamespace or require and check the return value) nor to find details of a small number of packages (use packageDescription).

And the recommended way to test for package availability should be requireNamespace("pkg", quietly = TRUE).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions