r-lib / usethis

Set up commonly used 📦 components

Home Page:https://usethis.r-lib.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use existing R versions for minimum required version

Bisaloo opened this issue · comments

usethis::use_data() automatically adds a minimum required R version:

usethis/R/data.R

Lines 47 to 51 in 9e64daf

if (version < 3) {
use_dependency("R", "depends", "2.10")
} else {
use_dependency("R", "depends", "3.5")
}

But these version numbers do not correspond to any actual R version. In practice, this adds a dependency to R (>= 2.10.0) / R (>= 3.5.0).

This can cause issues when programmatically passing this version number to downstream tools (e.g., to lintr::backport_linter(), or to find the release date with the rversions R package). Instead of a single equality comparison, we now have to find the first version which matches an inequality comparison.

Is it possible to edit these lines to add the patch version number (.0)? As far as I can tell, it is a fully backwards-compatible change, since it only makes the de facto current behaviour explicit.

I'm happy to submit a PR for this if you agree with this minor change.

Adding more context from help(numeric_version) with additional emphasis mine:

Numeric versions are sequences of one or more non-negative integers, usually (e.g., in package ‘DESCRIPTION’ files) represented as character strings with the elements of the sequence concatenated and separated by single ‘⁠.⁠’ or ‘⁠-⁠’ characters. R package versions consist of at least two such integers, an R system version of exactly three (major, minor and patchlevel).

package_version("4.1")    # OK
#> [1] '4.1'
package_version("4.1.0")  # OK
#> [1] '4.1.0'
R_system_version("4.1")   # FAIL
#> Error: invalid version specification '4.1'
R_system_version("4.1.0") # OK
#> [1] '4.1.0'

Created on 2024-04-03 with reprex v2.1.0