Skip to content

Commit

Permalink
better message if it fails
Browse files Browse the repository at this point in the history
ref #137
  • Loading branch information
wibeasley committed Jan 13, 2024
1 parent 89599b0 commit faf78ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/assert-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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 <https://cloud.r-project.org>.")
"Your R version is too old. It is %s, but needs to be at least %s. Update it at <https://cloud.r-project.org>." |>
sprintf(
current,
minimum
) |>
stop()
} else {
TRUE
}
Expand Down

0 comments on commit faf78ce

Please sign in to comment.