diff --git a/R/skip.R b/R/skip.R index 75c4d99db..2b894beed 100644 --- a/R/skip.R +++ b/R/skip.R @@ -100,6 +100,12 @@ skip_if <- function(condition, message = NULL) { #' @param minimum_version Minimum required version for the package #' @rdname skip skip_if_not_installed <- function(pkg, minimum_version = NULL) { + # most common case: it's not installed + res <- tryCatch(find.package(pkg), error = identity) + if (inherits(res, "error")) { + skip(paste0("{", pkg, "} is not installed")) + } + # rarer: it's installed, but fails to load if (!requireNamespace(pkg, quietly = TRUE)) { skip(paste0("{", pkg, "} cannot be loaded")) }