r-lib / pkgbuild

Find tools needed to build R packages
https://pkgbuild.r-lib.org
Other
66 stars 35 forks source link

Export `version_info` or `rtools_needed` #97

Closed burgerga closed 4 years ago

burgerga commented 4 years ago

The latest R/Rtools release broke the installr::install.Rtools functionality (https://github.com/talgalili/installr/issues/148). I am working on a fix, but for this fix it would be very convenient if either version_info or rtools_needed would be exported. (Of course, it would be even more convenient if pkgbuild would have a function to install a compatible Rtools 😁)

What I was trying to do:

rtools_needed <- function(r_version = getRversion())
  tryCatch({
    version_info <- pkgbuild:::version_info
    version_info$custom <- NULL

    for (i in rev(seq_along(version_info))) {
      version <- names(version_info)[i]
      info <- version_info[[i]]
      ok <- r_version >= info$version_min && r_version <= info$version_max
      if (ok) return(version)
    }
  }, error = function(e) { })
  stop("Can't determine compatible Rtools version")
}

but because the ::: I don't think this is going to pass CRAN checks 😅 Happy to discuss options/opinions!

burgerga commented 4 years ago

Thanks! Still one issue, it always returns "Rtools custom", that is because it always checks it first and it's always ok, that's why I removed custom in my code above