Discovered when running the following, with my system unable to connect to CRAN.R-project.org:
available::available("testpkg")
#> Error in url(sprintf("%s/%s", cran, path), open = "rb") :
#> cannot open the connection to 'https://CRAN.R-project.org/src/contrib/Meta/archive.rds'
#> In addition: Warning message:
#> In url(sprintf("%s/%s", cran, path), open = "rb") :
#> URL 'https://CRAN.R-project.org/src/contrib/Meta/archive.rds': status was 'Couldn't connect to server'
Issue:
Currently, available_on_cran() calls tools:::CRAN_archive_db(). By default, tools.R uses "https://CRAN.R-project.org" (obtained from .get_standard_repository_URLs()) as the base URL to fetch, unless Sys.getenv("R_CRAN_SRC") is set.
This differs from the expected behavior, which would be to use a mirror or the value from repos.
A possible solution would be to set R_CRAN_SRC when calling tools:::CRAN_archive_db() to the repos parameter. Confirmed by setting Sys.setenv(R_CRAN_SRC = "https://cloud.r-project.org") and re-running available::available("testpkg").