You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several functions (use_release_checklist(), use_news_md()) call cran_version() to check if a package is on CRAN, which fails if a CRAN mirror is not set.
cran_version() calls available.packages() which in turn calls contrib.url() with repos = getOption("repos"). If the CRAN mirror is unset (the default value is "@CRAN@" in a factory fresh installation) it will prompt a user to choose in an interactive session, or fail otherwise:
withr::with_options(
list(repos= c(CRAN="@CRAN@")),
usethis:::cran_version()
)
#> Error in contrib.url(repos, type): trying to use CRAN without setting a mirror
This is showing up in revdep checks and CRAN checks for some usethis reverse depenencies which use use_news_md(). E.g., cynkra/fledge#683
cran_version() should not fail if there is no internet, or if there is no CRAN mirror set. In the former case, it should likely return NULL, which it currently returns if the package is not on CRAN. That seems like a reasonable fallback. If there is no CRAN mirror set we should try to set one locally, and also wrap that in a tryCatch(), returning NULL again if still unsuccessful.
This was surfaced in revdepchecks for #1849, was at first thought to be a false positive, and did not cause issues on incoming checks, but is causing failures for revdeps on CRAN.
If getOption(repos)["CRAN"] is NULL or NA (I don't know under what circumstances it would be set this way), cran_version() currently returns NULL. By locally setting a CRAN mirror we should be able to have success in more of these cases as well.
I don't have concrete plans because this is literally the only thing that would be in it. Since we just released 1 year's worth of maintenance, I suspect a few more smallish things will come up in the medium term. So maybe once there's a couple little things, we'll do a patch release.
Activity
ateucher commentedon Jun 8, 2023
If
getOption(repos)["CRAN"]isNULLorNA(I don't know under what circumstances it would be set this way),cran_version()currently returnsNULL. By locally setting a CRAN mirror we should be able to have success in more of these cases as well.Add failing test for unset CRAN mirror #1857
krlmlr commentedon Jun 12, 2023
Are you aiming for a point release anytime soon? Thanks!
jennybc commentedon Jun 14, 2023
I don't have concrete plans because this is literally the only thing that would be in it. Since we just released 1 year's worth of maintenance, I suspect a few more smallish things will come up in the medium term. So maybe once there's a couple little things, we'll do a patch release.
jennybc commentedon Jun 23, 2023
I ended up needing to do a patch release anyway, so this fix will presumably be in usethis 2.2.1.