r-hub/sysreqs

sysreqs:::detect_r_version() returns NA on 4.0.0-alpha

HenrikBengtsson opened this issue · 3 comments

sysreqs:::detect_r_version() returns NA on 4.0.0-alpha, which result in all kind of downstream errors, e.g. in if (...) statements.

> sysreqs:::detect_r_version()
[1] NA
> sessionInfo()
R version 4.0.0 alpha (2020-04-02 r78141)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /home/hb/software/R-devel/R-4-0-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-4-0-branch/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.0     backports_1.1.6    assertthat_0.2.1   R6_2.4.1          
[5] rprojroot_1.3-2    crayon_1.3.4       sysreqs_1.0.0.9000 debugme_1.1.0     
[9] desc_1.2.0

The issue seems to be that detect_r_version() can only works for r-release (4.0.2 at time of this writting) and r-oldrel (3.6.3). For any other version, it returns NA. The relevant code is here:

detect_r_version <- function() {

detect_r_version() currently returns NA for R 4.3.0 and I'm hitting this issue too.

@jeroen @gaborcsardi The R version is downloaded from http://rversions.r-pkg.org/r-release and this currently returns "4.2.3". Where can we update this to "4.3.0"?

Back to the original issue, I'm seeing:

sysreqs::current_platform()
#> Error in `if (rver == "r-devel" && os == "osx") ...`:
#> ! missing value where TRUE/FALSE needed

This patch fixes it:

modified   R/platform.R
@@ -46,7 +46,7 @@ detect_platform <- function() {
   ## r-devel-linux-x86_64-debian-gcc
   ## r-devel-linux-x86_64-fedora-clang
   ## r-devel-linux-x86_64-fedora-gcc
-  if (rver == "r-devel" && os == "linux") {
+  if (identical(rver, "r-devel") && identical(os, "linux")) {
     platform <- paste(
       sep = "-",
       platform,
@@ -56,13 +56,13 @@ detect_platform <- function() {
   }
 
   ## r-devel-osx-x86_64-clang
-  if (rver == "r-devel" && os == "osx") {
+  if (identical(rver, "r-devel") && identical(os, "osx")) {
     platform <- paste(platform, sep = "-", comp)
   }
 
   ## r-release-osx-x86_64-mavericks
   ## I am not completely sure what this is, btw.
-  if (rver == "r-release" && os == "osx" && pkgtype == "mavericks") {
+  if (identical(rver, "r-release") && identical(os, "osx") && identical(pkgtype, "mavericks")) {
     platform <- paste(platform, sep = "-", "mavericks")
   }
 

However it might be better to:

  • Return "" instead of NA in all these detection functions so that == works as expected.
  • Detect NA / "" R versions and throw an error since the platform resulting from the patch above does not seem standard: "NA-osx-x86_64"

Use https://api.r-hub.io/rversions/ instead, e.g. https://api.r-hub.io/rversions/resolve/release/macos

What are using the sysreqs package for? pak is a better alternative for installing system requirements.