From faf78ce5a9cc3ac845af3260351b073d71519604 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Fri, 12 Jan 2024 20:00:00 -0600 Subject: [PATCH] better message if it fails ref #137 --- R/assert-version.R | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/R/assert-version.R b/R/assert-version.R index ed5478d..bf00881 100644 --- a/R/assert-version.R +++ b/R/assert-version.R @@ -32,7 +32,7 @@ #' @export assert_version_r <- function(minimum = base::package_version("4.2.1")) { checkmate::assert_vector(minimum, len = 1, any.missing = FALSE) - v <- + minimum <- if (inherits(minimum, "package_version")) { as.character(minimum) } else if (inherits(minimum, "character")) { @@ -47,11 +47,16 @@ assert_version_r <- function(minimum = base::package_version("4.2.1")) { comparison <- utils::compareVersion( current, - v + minimum ) if (comparison < 0 ) { - stop("Your R version is too old. Update it at .") + "Your R version is too old. It is %s, but needs to be at least %s. Update it at ." |> + sprintf( + current, + minimum + ) |> + stop() } else { TRUE }